- Home /
Player exits car, need proper rotation - syntax help.
Sorry been a long day.
EDIT : C#
Hey guys. So I've got a player that exits a car, the direction hes facing is the original when he got in (which could be anything when the player goes to get out) I want to fix this. I could have him look at the car, but I want to add a + 90 degree look off of that. I already have the look at car setup, I cannot however find the correct syntax to tact on a +90 look from the car...
I mean I could put a inv object in front of and slight left of the car - but there has to be a better method?
Answer by pickle chips · Jun 30, 2013 at 02:25 AM
I'm not sure what exactly what you have for code, but assuming in the script you already have a reference to the player and the car, you could use this :
c#:
//Code to exit Car Here//
//Setting rotation
player.rotation = new Vector3(0, car.rotation.y + 90, 0);
JS:
//Code to exit Car Here//
//Setting rotation
player.rotation = Vector3(0, car.rotation.y + 90, 0);
This set's the players rotation around the y axis to the same as the car (So it would be facing the same way) and then adds 90 degrees to it. (Note: the rotation added may need to be some other increment of 90 degrees to get it to face the direction you want)
Yea that pretty much was what I was after Pickle Chips. I'll give it a try but I'm sure it'll work.
Your answer
Follow this Question
Related Questions
How to do transform.LookAt() from a different part of object? 1 Answer
transform.LookAt(target); 4 Answers
Need help with Transform.LookAt 1 Answer
Can't get Transform.LookAt to work 3 Answers
How to slow down transform.LookAt 6 Answers