- Home /
Clamp Camera with Transform objects along the x axis
void FixedUpdate() {
transform.position = Vector3.SmoothDamp (transform.position, destination, ref velocity, dampTime);
transform.position = new Vector3(Mathf.Clamp(transform.position.x, beginBorder.position.x, endBorder.position.x), transform.position.y, transform.position.z);
}
I need to restrict the camera along the x axis. I have a two game objects that I use (begin border and end border) to determine this. Unfortunately this is not working with different resolutions and aspect ratios.
I have tried using fixed numbers for min and max and unfortunately that doesn't work either. Any suggestions?
Your answer
Follow this Question
Related Questions
Handle with camera 1 Answer
Same visible area with every resolution 2 Answers
2D Aspect Ratio Of Camera 2 Answers
First person camera restriction. 1 Answer