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?
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);
}
}
}