- Home /
how to move an object (noob)
i have a topdown game and i want to move an enemy along the x axis. how can i achive this?
Answer by tylo · Aug 28, 2010 at 04:51 PM
As you delve deeper into Unity, you will find that there are multiple solutions. I favor using forces, which require that you add a Rigidbody component to your GameObject inside of the editor.
Then, in your script, you would add this:
var thrust : float = 100.0;
void FixedUpdate() { //Use FixedUpdate for Physics changes rigidbody.AddRelativeForce(Vector3.Right thrust Time.deltaTime); }
If you'd like a more detailed tutorial on forces and movement, you can visit a tutorial I wrote here:
Answer by GesterX · Aug 28, 2010 at 04:53 PM
The answer to this question as well as some more on scripting basics can be found in the basic scripting tutorial
http://docwiki.unity3d.com/uploads/Main/Scripting%20Tutorial.pdf