- Home /
Restrict Camera movement in its local space
I have a problem, which at first may seem to be solvable with Mathf.Clamp and stuff, but this is not the case I believe. I have a camera which is orbiting around a certain point in space. The camera is tilted in different angles, but always pointed towards the target. Now, I want to pan with the camera sideways, along its local x-axis. This I do with transform.localPosition = transform.localPosition + transform.right * movement;
But I want to restrict the panning in a certain boundary, i.e. (minX, maxX) the camera will not pan sideways 0.1 units along its x-axis, from the target it is looking at. Anyone knows a simple way how to do this? AFAIK this is not a simple case of checking transform.localPosition.x > maxX, as the movement along the camera's x-axis (transform.right) influences the other coordinates depending on the rotation of the camera.
Your answer
Follow this Question
Related Questions
Is there an elegant way of limiting camera's position? 1 Answer
Forward and back movements with a camera emulating an isometric view 1 Answer
Buttons move with the camera and I don't want that 0 Answers
Help with Texture following Camera!/How to create an effect like this in Unity 3d? 1 Answer
Position far away from center of map generates artifacts 1 Answer