- Home /
Transform.Translate() coordinates confusion
Hi, I'm trying to move a Sphere "down", i.e. negative in the y-axis, but it goes positive in the z-axis.
I did not change any rotation, and I tried both Space.Self and Space.World.
I also searched for this is here and Google, none of the answers helped me, and I am always having this confusion, so please end this here :)
My function is a very basic function like this: (JavaScript)
function Update()
{
//I tried all of these lines SEPERATELY:
transform.Translate(transform.up*Time.deltaTime);
transform.Translate(transform.right*Time.deltaTime);
transform.Translate(Time.deltaTime*transform.forward);
transform.Translate(new Vector3(0,-Time.deltaTime,0));
transform.Translate(new Vector3(-Time.deltaTime,0,0));
transform.Translate(new Vector3(0,-Time.deltaTime,0),Space.Self);
transform.Translate(new Vector3(0,-Time.deltaTime,0),Space.World);
}
All of these lines cause the sphere move in the positive z-direction. Any ideas why? and how do I solve this problem?
Thanks in advance.
Answer by jerobinson · May 31, 2013 at 10:26 AM
Try using:
transform.Translate(-Vector3.up * Time.DeltaTime, Space.World);
That should move it in a negative y direction. As for why your other attempts didn't work, I'm not entirely sure. Another way to do it would be:
transform.Translate(0, -Time.DeltaTime, 0);
Answer by TomMakesGames · May 31, 2013 at 10:21 AM
Is there something in the options that changes the direction of the z-axis? I don't know Unity too well yet, but I know that when Maya is used for games we usually need to change 'up' to be positive z instead of positive y.
If so, it could be interpreting what you think is a y translate into a z translate.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Vector3 Returning Infinity Error 2 Answers
transform.Translate and transform.eulerAngles bug 0 Answers
Get rotation in self coordinate system 1 Answer
Opposite direction in Trigger Enter 1 Answer