Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can I translate all the particles' position by a certain vector?
#3
Hi,

Thanks for that. I tried to make a coroutine for that, but I don't understand some of the structures involved, as well as the presence of a Vector4 as the translation.
Please see my code below. Note: the platform is moved by IK, so the movement happens at the end of the frame.
What did I do wrong there?

Code:
public IEnumerator ParticlesFollowPlatform_IE()
    {
        float duration = 3;
        float i = 0;

        Vector3 translation = platform.position - platformLastPosition;
        platformLastPosition = platform.position;

        while (i < duration)
        {
            yield return new WaitForEndOfFrame();

            i += Time.deltaTime;

            Vector3 translation = platform.position - platformLastPosition;
            platformLastPosition = platform.position;

            for (int x = 0; x < myActor.solverIndices.Length; x++)
            {
                int solverIndex = myActor.solverIndices[x];

                myActor.solver.positions[solverIndex] += new Vector4 (translation.x, translation.y, translation.z, 0) ;
                myActor.solver.prevPositions[solverIndex] += new Vector4(translation.x, translation.y, translation.z, 0);
            }
        }
   }
Reply


Messages In This Thread
RE: Can I translate all the particles' position by a certain vector? - by emz06 - 11-09-2020, 11:57 AM