How can I fix my loop steps to the framerate?

Hi, I’m new to Unity so I apologize if my question is posed poorly.

I want to use a loop to execute the following until a condition is met:

transform.Translate (Vector3.right * (Time.deltaTime * speed));

However whenever I do so, rather than translating the object at a rate of speed per second it steps through the entire process before the frame can end.

Is there a way I can set the loop to execute one step per framerate? Or perhaps I’m being silly and there’s a much better way to do this.

I assume what I really need for this is a timer but I’m not quite sure how to set one up other than putting a pause in each step.

What you’re looking for is: Unity - Scripting API: MonoBehaviour.Update(). “Update is called every frame”. By placing your code inside the update method, it will be run every frame. You mentioned setting it up so it ran until a condition is met, to do that you can add a “while” statement with a condition.

If you’re unsure of how to setup a monobehaviour for a script, you should consult the video learning series from the official Unity website: https://unity3d.com/learn/tutorials/topics/scripting.