# Continuous translation in Unity

I would like to apply a constant-speed everlasting translation to a game object (e.g a background) in Unity. Without physics.

What is the best way to achieve that?

• What did you try? Did you try anything at all? Please refer to our FAQ on writing proper questions. – K.L. Mar 16 '15 at 10:44
• Where is this FAQ, please? – sdabet Mar 16 '15 at 10:52
• gamedev.stackexchange.com/help/asking here you go :) – K.L. Mar 16 '15 at 10:55
• Thanks. I haven't tried anything yet. I was wondering what was the best practice to achieve this common problem in Unity. But maybe it's not the appropriate stackexchange site for that. Sorry if it's the case. – sdabet Mar 16 '15 at 11:04

There is no one "best way" and what is best is subjective.

The method I present is quite simple - just change the position over time. Use Time.deltaTime so the motion seems fluid regardless of the length of the frame. You can substitute for Vector3.forward with any other vector with the magnitude of 1 - it decides in what direction does your object move.

I dont have access to Unity right now to test it, but the script would look similar to this:

float speed = 1.0f;

public void Update()
{
Vector3 newPosition = transform.position + (Vector3.forward * speed * Time.deltaTime);
transform.position = newPosition;
}

• That sounds good. Thanks. Of course when I say "best way" I mean "the simplest and most obvious way which would commonly be considered as a best practice" (but I thought it would just make the question more confuse...) – sdabet Mar 16 '15 at 10:58
• This is pretty much it. Translating some direction at speed X and accounting for time passed is as simple as it gets. There are other ways (animations w root motion, using physics and applying force, etc). But those are generally going pointlessly out of the way for something very simple. – DrHeinous Mar 16 '15 at 20:58