Hi there! I have been refraining from asking this question for a long time, but I cannot find a similar case online. So here goes.
I have an array of GameObjects and I am interested in translating them all at the same time. To do this, my approach was to loop through the array, toggle a bool in the GO to true, and use the GO’s update method to perform the translation. This works when the GO’s Update method looks like this:
void Update()
{
if(moveThis == true)
{
transform.Translate(0,0,0.01f);
}
}
This works fine! But when I add additional logic to limit the translation such as this:
void Update()
{
if(moveThis == true)
{
float x = 0f;
while (x < 5f)
{
transform.Translate(0,0,0.01f);
x += 0.04f;
}
moveThis = false;
}
}
All of the objects teleport to their destination. I have tried this with lerp, translate, and transform.position += new Vector3(x,y,z), but they all give this teleporting behaviour. Any insight into this would be greatly appreciated! Thanks and have a great day, cheers!