Hello I wondered how I can code a limit to my camera movement.
Right now my camera can rotate 360°, but thats way to much.
After searching a solution on Google I came up with Mathf.Clamp.
I tried this out a bit, but I cant find a way to implement this in my current code.
This is my code:
float edgeSize = 40f;
if (Input.mousePosition.x > Screen.width - edgeSize)
{
//EdgeRight
transform.RotateAround(this.transform.position, Vector3.up, rightSpeed * Time.deltaTime);
}
if (Input.mousePosition.x < edgeSize)
{
//EdgeRight
transform.RotateAround(this.transform.position, Vector3.up, leftSpeed * Time.deltaTime);
}
I also created a float:
public float rotationY = 0.0f;
And used Mathf.Clamp:
rotationY = Mathf.Clamp(rotationY, 50f, 130f);
Maybe you guys can give me a hint on what to do.
Thanks