- Home /
Camera Stays in the Center
Hi,
Currently, I have a camera set to follow the hero in a 2d game. The current camera focuses on the hero and stays in the center of the screen, but I would like the camera to follow the hero but stay at the bottom of the screen. How would I do that? I have a very simple camera script.
Here is a snippet:
function Update (){
transform.eulerAngles = Vector3(0,0,0);
}
How do I accomplish my goal? Other than the above script, the camera values are the default settings.
Thank you for your assistance.
Could you clarify what you mean by having the camera "at the bottom of the screen"? The camera essentially "is" the screen, so it's a little unclear as to what you're attempting to do.
So, within the frame, I want the hero to stand on his platform on the bottom of the frame. Right now, the hero stands on the platform which is in the center of the frame. Does that make sense?
Ahh, yes, that helps a great deal. One further question: Is the camera a child object of your Hero in the scene hierarchy?
Yes, the camera is a child of the hero. It is connected to the hero via an empty gameObject. So it is Hero>>GameObject>>Camera.
Answer by dwsarber · Apr 29, 2012 at 07:06 AM
If I'm understanding your question and comments correctly, then it seems all you need to do is set the Y position of the camera to some positive value. Assuming the camera object doesn't have a rotation other than the default, setting it to a larger Y position will make the Hero appear where you want in the Viewport (in this case at the bottom). Since the camera is a child of the Hero, it will continue to automatically follow him around, even with this new position.
Are you saying to increase the value of the Y in the Normalized View Port? I can't set it any higher than like 1.0 and I'm not seeing any difference. As for like the y-axis of the camera, that doesn't make sense to me since it will rotate the camera...
@ the first comment, you want to increase the Y Position value in the Transform component of the camera. It will move it "up" relative to its parent object. The only way it rotates is if you change the Rotation values in the Transform, or its parent object rotates (in the same way).
@ the second comment, each camera will only ever be looking at one object or in one direction at a time. It could be possible to have two objects/directions be the focus, but the camera would have flip back and forth between them.
Your answer
Follow this Question
Related Questions
how to request location , camera permission during run time ? 0 Answers
How to make camera position relative to a specific target. 1 Answer
Where to put camera orbit around player script? 1 Answer
iPhone tracking distance from computer? 0 Answers
Need to Find Distance Between Mouse Cursor and Object in a 2.5D SideScroller 1 Answer