- Home /
I want a camera to be a child of my player but not to follow it's rotation
Now, as noobish as this question seems, I could not find an answer. I need my camera to be a child of my player, and follow it around but not rotate. Now, I know how to make a script that makes your camera follow the player, but that works only if the camera is not a child of my player. I want my camera to be a child of my player because I'm doing networking stuff and I need the player and camera to be one gameObject, but I can't make a new empty gameObject because I need my player to be the root parent. Does anyone have a Idea of what I could do? ps. adding a rigidbody to the camera and making the camera kinematic or freezing it's rotation doesn't work
Answer by ParadoxSolutions · Mar 22, 2016 at 03:57 AM
I don't see why you can't have your script that makes the camera follow the player work on a child of the player. Can't you do
void Update() { gameObject.transform.position = gameObject.transform.parent.transform.position; }
and have the camera as a child following the parent GameObject? (note: not tested)
I meant for this to be a comment not an answer (oops) but if it works, that's cool.
No, because the camera and player have to be one gameobject and the player needs to be the root parent, hence the requirement. I also tried to set the parent to null once loaded, but the camera keeps following the wrong player
Answer by aida12_99 · Mar 23, 2016 at 11:51 AM
Have you seen the answer on the URL below? http://answers.unity3d.com/questions/423031/how-do-i-set-a-child-object-to-not-rotate-if-the-p.html