Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make the Start/End Prefab able to be Raycasted?
#8
(01-11-2017, 11:23 AM)Rexima Wrote: Thank you very much for your help, but how do i know the new position of each particle?

I need to add all Particles once, and than i need to move the handler where my "hand" is.
But the problem is, how to add all Particles, how do i know the new position of them?

This is in my Init void:


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


           // Add the selected particle(s) to the handle:
           for (int i = 0; i < m_rope.invMasses.Length; ++i)
           {
               m_handle.AddParticle(i, m_rope.GetParticlePosition(i) / m_rope.invMasses[i], m_rope.invMasses[i]);
           }

And this in FixedUpdate to move the Handler:


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

In the Attachment you can see, how it looks, when i pick the rope up.

Hi!

Why do you divide the position of each particle by its mass when initializing the handle? It doesn't make sense in this context... and will yield completely incorrect results for your purposes. Also, you're adding ALL particles in the rope to the handle. I was under the impression that you only wanted the first/last particles to be handled, and let the rest of the rope be simulated.

The initial position of each particle in the handle must be the one you wish them to be in relation to the handle. For instance, if you wish the particle to be exactly on top of the handle, then you must pass the handle's position. Passing the current particle position as you do now, will NOT make the particle "teleport" to the handle position at the start, it will make sure the particle keeps that position relative to the handle.

 From then on, the handle itself will make sure that the particles keep the same position in its local space. You no longer need to do anything once the handle has been set up. Just moving the handle around will be enough.
Reply


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