17-09-2020, 11:37 AM
Hi there,
I replied again to the thread about translation of particles but you may have not seen it pop up.
I'm trying to use the vector4 structure to move particles as your code suggested, but I'm not sure how to use it.
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?
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);
}
}
}
I replied again to the thread about translation of particles but you may have not seen it pop up.
I'm trying to use the vector4 structure to move particles as your code suggested, but I'm not sure how to use it.
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?
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);
}
}
}