Question by
Liraseth · Oct 09, 2019 at 08:00 PM ·
cameracamera rotatecamera-lookcamera movementcamera rotation
Maximum Camera Angle Rotation
For now panning the camera above and under the player results in a full 360 all around it. I wish to be able to stop the rotation on the top and the bottom of the player.
This is my camera script so far...
public class CameraController : MonoBehaviour
{
public float turnSpeed = 4.0f;
public Transform player;
private Vector3 offset;
void Start()
{
offset = new Vector3(player.position.x, player.position.y + 8.0f, player.position.z + 7.0f);
}
void LateUpdate()
{
offset = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * turnSpeed, Vector3.up) * offset;
offset = Quaternion.AngleAxis(Input.GetAxis("Mouse Y") * turnSpeed, Vector3.left) * offset;
transform.position = player.position + offset;
transform.LookAt(player.position);
}
2019-10-06-16-22-39-2.gif
(522.0 kB)
Comment
Your answer
Follow this Question
Related Questions
Third person look around camera, jagged results 0 Answers
Camera rotation 2 Answers
Make camera follow and look at object at the same time 0 Answers
How to recreate the Silent Hill 1 camera style? 0 Answers
How to rotate camera diagonally over players shoulder while still facing towards players direction 0 Answers