- Home /
 
Camera problem
I am trying to make a 2d game just for fun, I am having some problems with the camera. When I rotate the player the camera rotate too because is child of player, but I want to rotate just the player. Can someone help me with this?


Answer by Happy-Zomby · Dec 01, 2014 at 07:44 AM
I would recommend you make the camera a seperate object and then put a script on it so it follows the player. E.g:
 private var heightOffSet : Vector3 = Vector3(0,400,0);    //height offset from player for camera
 private var player : GameObject;            //the main player game object
 
 function Start ()
 {
 player = GameObject.Find("Player");    //find game object player and assign
 }
 
 
 function Update ()
 {
 //follow player position    
 transform.position = player.transform.position + heightOffSet;        //have the camera follow the player based on current height offset
 }
 
               you'll need to play with vector height offset to set it to your needs... angle the camera how you like it and then use this to set the distance - you'll need to use position x y z depending if your game is top down or side view...etc... hope that helps,
Answer by tanoshimi · Dec 01, 2014 at 07:22 AM
Child objects are positioned relative to their parent. So don't make the camera a child of the player.
Hi Igorfm.Dont use camera as a child of player.if u wanted to do so..then use sprite animation to control player ins$$anonymous$$d of using 3d model or any other method to avoid complexity and to reduce game size..
Your answer
 
             Follow this Question
Related Questions
Player's movements doesn't match orbital camera 1 Answer
Problem in rotating camera around a moving player 1 Answer
Moving Player Relative to Camera? 1 Answer
3rd Person Orbit Camera in LOCAL Space 0 Answers
Rotate Camera to the object 0 Answers