Making a third-person camera seem easy, but the hard part is the collision. I’ve done it before, but there was a drawback; the camera won’t revert to it’s original position, and the player’s head pops off the body following it. So there went that. I think making the wall transparent for the camera might make things easy. Here’s the script so far:
{
public float RotationSpeed;
public Transform Target, Player;
float mouseX, mouseY;
public Transform Obstruction;
float zoomSpeed = 2f;
void Start()
{
Obstruction = Target;
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}
void LateUpdate()
{
CamControl();
}
void CamControl()
{
mouseX += Input.GetAxis("Mouse X") * RotationSpeed;
mouseY -= Input.GetAxis("Mouse Y") * RotationSpeed;
mouseY = Mathf.Clamp(mouseY, -45, 10);
transform.LookAt(Target);
Target.rotation = Quaternion.Euler(mouseY, mouseX, 0);
Player.rotation = Quaternion.Euler(0, mouseX, 0);
}
}
If anyone’s got an idea or two, I’d be happy to hear it.