- Home /
how to get local "up" in global space?
hello everyone, I am trying to do a script for the camara to moove smoothely, it was all working perfectly untill i added "transform.LookAt", this made my camera unable to go upside down and, since it`s for a space fighter, it becomes disturbimg. tried the following(according to the little i remember about vectors):
localUp = new Vector3(Mathf.Cos(transform.rotation.z), Mathf.Cos(transform.rotation.y),
Mathf.Cos(transform.rotation.x));
*local up is a vector 3 variable
all i got from it was the camera to start sideways and to wobble when i turn. im out of ideas, if someone knows how to do this pls tell me.
thanks in advanced.
I know it's correct and proper, but I laughed aloud to read your secondary alternative, @robertbu . It's good to show that that approach exists - just struck me that it looks silly. ;)
@AlwaysSunny the second approach mainly exists because sometimes you want to convert a vector from local space to world space that is not up, right, left, down, forward or back.
@Bored$$anonymous$$ormon, of course, of course. I'm such a big fan of Convenience Wherever Possible it offends my obsessiveness to behold such tomfoolery. ;)
In included the alternate because it is common in older code posted to Unity Answers, and it is good to recognize what the code is doing.
Answer by robertbu · Nov 06, 2014 at 11:30 PM
Not sure it is the right solution for your problem, but local up in world space is 'transform.up'. You can get it also by 'transform.TransformDirection(Vector3.up)'.
Your answer
Follow this Question
Related Questions
slowly rotate a object *need quick fix* 0 Answers
Local Rotation and then Global Rotation 1 Answer
How do I align my player transform to waypoints and without restricting Z Axis rotation? 2 Answers
Convert local forward into world vector 1 Answer
How do you make a gameobject rotate slowly to the direction of the mouseclick 0 Answers