You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
741 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class DontRotate : MonoBehaviour {
  5. private Quaternion originalRot;
  6. public float maxAngle;
  7. public float turnSpeed = 0.5f;
  8. // Use this for initialization
  9. void Start () {
  10. originalRot = transform.rotation;
  11. }
  12. // Update is called once per frame
  13. void Update () {
  14. transform.rotation = originalRot;
  15. }
  16. // Update is called once per frame
  17. void lookAtDir(Vector3 inputDir) {
  18. Quaternion targetRotation = Quaternion.LookRotation(inputDir, Vector3.up);
  19. float str = Mathf.Min(turnSpeed * Time.deltaTime, 1);
  20. transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, str);
  21. }
  22. }