- Home /
How to Keep Player in the Center of the Screen?
Hello,
I'm using the 2D Side Scroller template for an iOS game. I need to make a few adjustments to the Smooth Follow 2D Script.
When my player falls for an extended period of time, he falls off of the camera.
I want him to stay in the camera's view, not slide out of view.
I've done many searches but still have not come across the information I need.
I'm not sure what I need to do. Here's the code:
function LateUpdate()
{
thisTransform.position.x = Mathf.SmoothDamp( thisTransform.position.x,
target.position.x+horizontal, velocity.x, smoothTime);
thisTransform.position.y = Mathf.SmoothDamp( thisTransform.position.y,
target.position.y+height, velocity.y, smoothTime);
}
Any help or pointers would be very appreciated.
Thanks.
Your answer
Follow this Question
Related Questions
Camera change script not working. 1 Answer
How to reset character orientation based on direction the camera is facing 1 Answer
How to always have the mouse curser in the center of your game ? 3 Answers
How to make a character move towards a side of the screen that's pressed at a constant rate? 2 Answers
Is it possible to keep the same Vector3 value using ScreenToWorldPoint with the camera moving? 0 Answers