Technology Programming

How to Move Objects at a Constant Speed in Unity

Instructions

1

Enter the following code into your game script to create a constant speed variable:

var ConstantSpeed : float = x;
2

Replace the "x" with the numerical speed value that you want to apply to the moving object.
3

Enter the following code into the script of your object to create an update function:

function Update ()
{
}
4

Type the following code between the brackets of the update function to apply the speed variable to the object:

transform.position.x = transform.position.x + ConstantSpeed;

Leave a reply