- Home /
Rotate camera with easeout
Hello! I've a script that rotates my camera the more fast the more the mouse reaches the screen boders.
float xMouse = Input.mousePosition.x;
float x1 = Screen.width * 30 / 100;
float x2 = Screen.width * 70 / 100;
float maxSpeed = 60.0f;
float div = 50000.0f;
if (xMouse < x1) {
float ang_speed = Mathf.Min (maxSpeed * ((x1 - xMouse) * (x1 - xMouse) / div), maxSpeed);
Camera.main.transform.RotateAround (Vector3.zero, -Vector3.up, ang_speed * Time.deltaTime);
}
if (xMouse > x2) {
float ang_speed = Mathf.Min (maxSpeed * ((xMouse - x2) * (xMouse - x2) / div), maxSpeed);
Camera.main.transform.RotateAround (Vector3.zero, Vector3.up, ang_speed * Time.deltaTime);
}
It works well but when i move the mouse towards center of screen the rotation stops instead of slowing down... Some help plz?
Comment
Your answer
Follow this Question
Related Questions
Make my camera turn smoothly 2 Answers
Smooth Camera Rotate 2 Answers
How to rotate the camera smoothly for just 1 second? 2 Answers
camera smooth stop (continuously sliding), on touch end 0 Answers
Turn page, smooth rotate 1 Answer