Vector3.up,down,right,left

This is a tricky one. Can anyone tell me why Vector3.down rotates an object on the X axis and the Vector3.up rotates it on the Y axis? Vector3.down isnt even in the Unity Reference. Vector3.right and left rotates the object at diagonal and also rotates the Y and Z to 180 in the process which causes the face to turn sideways.

Basically, Im looking for a way for it to rotate the cube downward, upward, left and right. I thought the Vector3 calls like up and down would rotate them the direction they are named.

This is screwy. Maybe its my code:

void Update()
{
    if(splashScreen)
    {
        // Smoothly rotates towards target 
        var targetPoint = targetPosition.transform.position;

        targetRotation  = Quaternion.LookRotation(targetPoint, Vector3.right);
    }

    transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 2.5f);    
}

does it have the same effect of you replace Vector3.down with -Vector3.up ? (i also edited your code format) =] The other consideration is Vector3.down is referring to World-Space. You may be looking for transform.down (-transform.up)

–

is your initial rotation (0,0,0)? since you are using slerp, I expect it just finds the shortest route to the desired rotation..

–

Yes it has the same effect. I changed it to Lerp and it does the same.

–

4 Answers

4

Quaternion target = Quaternion.Euler(10, 0, 0);
transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth);

This is exactly what I was looking for. This simple rotates which ever coordinate you want. Each coordinate will rotate the number of degrees the player pleases.

Thanks anyway all! =D

Vector3.up, down, left right etc are simply shorthand for writing out the Vector3 declaration in full.

So Vector3.Up is shorthand for Vector3(0, 1, 0).

y is usually the up axis in most cases.

So basically the LookRotation method rotates on that specific axis.

I understand the definition. But that doesnt tell me why Vector3.up isnt the opposite of Vector3.down. And when it says that both down and right/left all manipulate the X axis, but all move in different ways.

–

I think maybe you misunderstood this Quaternion.LookRotation() function.

It simply doesn’t give you “the rotation by how much angles on each axes you would like it to rotate”.
It gives you “the rotation by how you’d like it to be after the rotation”.

So, comparing which direction of the rotation happened during your practice is meaning less as you should only be granted a correct final answer which is “looking at targetPoint with the direction given by the second parameter on the head”.

And yes, what you need is Quaternion.Euler(). Glad you find it after all.

Unity is the site where you can access your goals. They give opportunities to develop a certain system for those people who interact online with people. You can see this page to create a 3D platform for yourself as well. Sign up and create your account.