Hi all, Im back working on my trasform script now, and assigned it to a root joint of a mesh.. Im using this code but I want the thing to move in the x, and z axsis only.. Not working! Code (csharp): transform.Translate (Input.GetAxis ("Horizontal") * (20 * Time.deltaTime), 0, Input.GetAxis ("Vertical") * (20 * Time.deltaTime)); I have tried altering it in all possible directions and it moves in "x" but not in "Z", instead it moves in Y!? How do I change that (Im guessing that "Vertical" is not a promising word here)?
Maybe Im not explaining this the way I should; I have a mesh, this mesh I would like to transform in the X and Z axis when the user press the buttons: Code (csharp): X+ = Right arrow X- = Left arrow Z+ = Down arrow Z- = Up arrow So I thought I could just use Horizontal and Vertical for this job, and assign them in the x and Z slots of the Transform. Appearently not! so dear people, Any suggestions? Thanks!
I presume you have this inside the Update function: Code (csharp): function Update() { transform.Translate (Input.GetAxis ("Horizontal") * (20 * Time.deltaTime), 0, Input.GetAxis ("Vertical") * (20 * Time.deltaTime)); } The code you have seems like the way to go. Do you see the values of the transform change in the inspector?
Yeah, that code looks right to me. "Vertical" just refers to the name of the input. If you went to Edit->Project Settings->Input, you could just as easily change it to "zAxis" or "ForwardBackward" or "Lemonade." You'd then refer to it by that name in script instead of "Vertical". As far as what it's doing now, I would double check that you have no other code affecting the movement of your object, and that you're visualizing the right axis in 3D-space. I know I get tripped up all the time expecting Z to be the vertical axis. You could also try testing your code with constants instead of the input variables. For instance, you could put transform.Translate(1, 0, 1) in your update function and see how it moves. Oh, and translate might use local coordinates to determine the move, so you might check that your object isn't rotated 90 degrees in some direction, causing your axis to be rotated as well.
No wait a minute here; It isn't! When I look in the inspector the now called Xaxis is really the Y Axis!!
No.. Hehe.. I don't get this at all! It doesn't feel like a bug either, but I can post an example here if you would look though it (?).
Not sure still, but a normal cube works just fine.. I think Maya's joints get screwed up or something in Unity, or maybe I set it up in a wrong way in Maya (the Axis I mean!).. But it looks just fine ( the transform tool is pointing upwards-) Anyway the good thing is that you don't have to bother about it, but thanks for the help!