- Home /
How to move an object in world with script
I am a beginner in scripting and unity but how can i move with script an object in my scene?
Comment
Best Answer
Answer by Stormizin · Aug 16, 2013 at 12:56 PM
You can use a variable to set a constant move like:
private float speed = 5.5f; //Base Velocity
then apply this to your script in Update function to be called every frame and start moving ...
void Update(){
transform.Translate(speed * Time.deltaTime, 0, 0); //transform.Translate assumes this parameters: (X,Y,Z) put the speed variable where you want to move.
}
Hope it helps!