Moving a gameObject along x, y, and z axis

I have a basic cube GameObject. I am trying to get it to move along each axis (X, Y, Z) by one unit when the user clicks an HTML button in the Unity Web Player. I can get it to call the functions properly, but I am not sure how to actually change the X, Y, and Z positions through code. Basically I want it to do something like this:

-User clicks green button -Browser calls function that does the following

Function moveGreen() { cubeObject.x = cubeObject.x + 1; }

What do I need to add to my GameObject, and what is the syntax to make the adjustment to the position like in my pseudo code above? Any help is appreciated. Thanks.

1 Answer

1

This is C#:

transform.position += new Vector3(1,0,0);

Is that what you wanted to know? You need to create a new CS script and add it to your object. Call this from the Update() funciton, and it will move.