Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- [RequireComponent(typeof(Camera))]
- public class FlyThrough : MonoBehaviour {
- public Vector2 moveSensibility = Vector2.one * 15f;
- public Vector2 mouseSensibility = Vector2.one * 2f;
- public float shiftMultiplier = 3f;
- private float vertical { get { return Input.GetAxis("Vertical") * moveSensibility.y; } }
- private float horizontal { get { return Input.GetAxis("Horizontal") * moveSensibility.x; } }
- private float mouseX { get { return Input.GetAxis("Mouse X") * mouseSensibility.x; } }
- private float mouseY { get { return Input.GetAxis("Mouse Y") * mouseSensibility.y; } }
- private void Update() {
- var movement = transform.forward * vertical * Time.deltaTime + transform.right * horizontal * Time.deltaTime;
- if(Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
- movement *= shiftMultiplier;
- transform.position += movement;
- transform.Rotate(Vector3.up, mouseX, Space.World);
- transform.Rotate(transform.right, -mouseY, Space.World);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement