- Home /
Simplist way to rotate camera 180degrees on trigger?
Hi,
I'm trying to set up a series of teleporters in my scene that adjusts the fps camera's position and rotation. I've set up the change of position with no problems but can't get my head around rotating the camera on trigger by 'x' amount.
Here's my code so far:
var Camera_01 : GameObject; var Destination : Transform;
function OnTriggerEnter (other : Collider) { Camera_01.transform.position = Destination.transform.position; Debug.Log ("warping..."); }
Use the code button (the one with 0s and 1s on) ins$$anonymous$$d of using pre and code tags. Just select your code, hit the button and done
Answer by Mike 3 · Aug 03, 2010 at 10:26 PM
It should (hopefully) just be as simple as this:
Camera_01.transform.rotation *= Quaternion.Euler(0, 180, 0);
What is the purpose of the * character just before the equal sign??
It's multiply equals (multiply by, then assign back). In the case of quaternions, the multiply operator is used to rotate one quaternion by another
Hi $$anonymous$$ike, thanks for the reply. I thought I was displaying the code wrong in the message too!! Thanks for clearing that up. The code you gave me didn't seem to work. Is there anything that could be conflicting with the script?
It's very possible that if you're using the $$anonymous$$ouseLook script or something like that, it could mess about with it
That may be what is happening as I'm using a fps controller with $$anonymous$$ouseLook attached to it. Can you recommend a better way of doing this? Would it be worth using LookAt and telling the camera to look at something behind it on teleport?
Your answer
Follow this Question
Related Questions
Quaternion Slerp Sanity Check 1 Answer
transform.Rotate For an Certain Amount of Time 1 Answer
FPS, character arm movement 0 Answers
How to transform position? 2 Answers
Locking world rotation of child 1 Answer