Skip to content

Instantly share code, notes, and snippets.

@LaserKaspar
Created November 4, 2021 20:43
Show Gist options
  • Save LaserKaspar/2f20358e89dfe672d0bc98cf072715bb to your computer and use it in GitHub Desktop.
Save LaserKaspar/2f20358e89dfe672d0bc98cf072715bb to your computer and use it in GitHub Desktop.
(UnityEngine) Short and simple camera orbit script with zoom.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseOrbit : MonoBehaviour
{
public float sensivity;
// Update is called once per frame
void Update()
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensivity, 0, Space.World);
transform.Rotate(-Input.GetAxis("Mouse Y") * sensivity, 0, 0, Space.Self);
transform.GetChild(0).Translate(0, 0, Input.mouseScrollDelta.y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment