PlayerLookAt.cs 394 B

12345678910111213141516171819
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerLookAt : MonoBehaviour
  5. {
  6. public float speed = 5f;
  7. void Update()
  8. {
  9. float horizontal = Input.GetAxis("Mouse X") * speed;
  10. float vertical = Input.GetAxis("Mouse Y") * speed;
  11. transform.Rotate(0f, horizontal, 0f, Space.World);
  12. transform.Rotate(-vertical, 0f, 0f, Space.Self);
  13. }
  14. }