Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make the Start/End Prefab able to be Raycasted?
#6
(30-10-2017, 09:05 PM)Rexima Wrote: I made what you said and i can hold my rope now, but i when i pick it up, i have only the end and start prefab in my hands.
The rope is away  Ángel



Code:
   m_handleGO = new GameObject("Obi Handle");
   m_handle = m_handleGO.AddComponent<ObiParticleHandle>();
   m_handle.Actor = m_rope;

   void FixedUpdate()
   {
       if (m_rope == null)
           return;

       if (m_handleGO == null)
           return;

       if (m_handle == null)
           return;  


       m_handleGO.transform.position = Vector3.Lerp(transform.position, PlayerCamera.Instance.transform.position + PlayerCamera.Instance.transform.forward * .8f, Time.deltaTime * 20);

       // Add the selected particle(s) to the handle:
       for (int i = 0; i < m_rope.invMasses.Length; ++i)
       {
           m_handle.AddParticle(i, m_handleGO.transform.position, m_rope.invMasses[i]);
       }
   }
How do i set the position of each particle? Sorry for this questions, but i bought this asset a day ago and i can't understand how to use it  Sonrojado

Hi,

FixedUpdate runs once (or zero, or multiple times) per frame, so your code is creating a handle and then adding the same particle to the handle every frame, setting its position to be whatever position the particle has that frame. This is wrong. 

Particles should only be added once, with the position they should have relative to the handle. The handle will take care of positioning the particle so that it keeps the same position relative to its frame, no need to manually set particle positions if you're using handles.
Reply


Messages In This Thread
RE: How to make the Start/End Prefab able to be Raycasted? - by josemendez - 31-10-2017, 02:43 PM