- Home /
Setting Rotations
So I'm having a bit of an issue like this: If I get out of my car and it just so happens to be on top of, say, someone's body, the camera for the player is stuck at the same rotations as the car was when you got out. I feel like this is a simple thing to fix with a transform.eulerangles, or something like that, but I'm a bit confused as to exactly how to word it. Here's how I instantiate my player:
Player = Instantiate(GameObject.Find("Clone"), exitPosition, transform.rotation) as GameObject;
I'd like to use a variable exitRotation in place of transform.rotation, and make it so that when I get out, I'm still facing the same direction as the car, but I'm looking level at the world. So basically, set x and z to zero, but keep y (unless I'm getting my axis mixed up :P)
Answer by DaveA · Aug 24, 2011 at 03:33 PM
Try using something like
car.transform.forward
I'm not looking to move the car itself. Whenever I get out of the car, I create a new player model, and then give control of that new model to the user. Unfortunately, whenever I do that, it copies all the rotations, when all I want it to copy is the y rotation.
Answer by NathanSix · Jan 14, 2016 at 03:08 PM
how about transform.rotation.y
or maybe call these codes after
transform.rotation.x = 0.0; transform.rotation.z = 0.0;
maybe something like transform.rotation(0,0,0)
Your answer
Follow this Question
Related Questions
How do I clamp the Z-Axis Rotation for this code? 1 Answer
Using euler angles to rotate causes the object to get stuck on the x axis? 1 Answer
Counter clockwise rotation with lerp 1 Answer
How to get find euler angle provided I have Transformation Matrix 1 Answer
Problems caused by non-unique Euler angle solutions 1 Answer