- Home /
Camera follows rotation. How can I fix it?
So I'm a real beginner in Unity3d. I want to make a snowboard game and to simulate a trick I want to play an animation when I hit "F" while I'm in air. So I made an animation where my player (a cube) rotates 360° and also a script which looks like this: if (jumpCount == true && Input.GetButton("Trick1")){ animation.CrossFade ("trick"); }
So this works but I have one problem: My camera (which is a child of my player) also rotates and I don't want this. How can I fix it? Sorry for my bad english...
Answer by Anxo · Nov 03, 2012 at 11:47 PM
you can tell the camera in an update fuction
transform.rotation = Quaternion.Euler(Vector3.zero);
that way your camera wont rotate at all
or you can make the camera not a child of the charater and jsut have it follow the character ins$$anonymous$$d.
Answer by Rappy · Nov 04, 2012 at 04:10 PM
"or you can make the camera not a child of the charater and jsut have it follow the character instead."
This worked! :) (the script didn't unfortunately)
glad it worked out for you, check the question off as answered and god luck.
Answer by Dexter.Unity · Nov 04, 2012 at 04:54 PM
You can create a new empty object: The player controller (just a point).
You make your player child of the player controller and also the camera. Now you can aim the camera at the player controller (point) and move and rotate your player without the camera following it's rotation or translation.
Then if you want the camera to follow the translation of you character you just make the translations apply on your player conrtoller insted of the player itself.
I hope it helps :)
This is the kind of out of the box thinking that I love that Unity brings.