Skip to content

Instantly share code, notes, and snippets.

@MrMagicPenguin
Created August 25, 2021 20:30
Show Gist options
  • Save MrMagicPenguin/47e1d673e40d1127b9995de65f402324 to your computer and use it in GitHub Desktop.
Save MrMagicPenguin/47e1d673e40d1127b9995de65f402324 to your computer and use it in GitHub Desktop.
// Pan
if (Input.GetMouseButton(1)) // right click
{
// Clamp bounds of *rig*
positionZ = Input.GetAxis("Mouse X") * moveSpeed;
positionY = -Input.GetAxis("Mouse Y") * moveSpeed;
// clamp position
newPosition.z += positionZ;
newPosition.y += positionY;
}
// Change position of camera
transform.position = cameraBB.ClosestPoint(newPosition);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment