- Home /
Put player at center-left on the camera
Hello I'm working on a side-scroller mobile game, and I'd like to stick the player at center-left on the camera. Since I want that the camera will follow the player, I've put the camera inside the Player gameobject. Then I wrote a simple script attached on the camera with: transform.position = new Vector3 (player.transform.position.x,transform.position.y,transform.position.z);
The problem is that the player is set at the center of the screen.. How can I solve this ? I tried to increse/decrese the player.transform.position.x on camera script, but I was not able to fix it for every resolution...
Thanks for the help
The simplest way would be to make the camera a child of the gameObject, but that would mean 1:1 movement. Assu$$anonymous$$g that you'd like it a bit prettier , you would probably want to make a little script, but that would depend on how you would like the camera to behave. You could also try searching for camera scripts and see if you can find one that fits your needs or one that you could modify.
Your answer
Follow this Question
Related Questions
Fixing the camera's left side in a 2D Game in all screen resolutions 0 Answers
Multiple Cars not working 1 Answer
What resolution should my game be? 2 Answers
Problem with Minimap. 3 Answers