Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / Scripts / NPC / WhaleBehaviour.cs
@Rackday Rackday on 21 Aug 807 bytes Project Added
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class WhaleBehaviour : MonoBehaviour
  5. {
  6. public float rotationSpeed;
  7. public Vector3 rotationAxis;
  8. public GameObject rotationPoint;
  9. private Vector3 perpendicular;
  10. [SerializeField]
  11. private PerpendicularVector pv;
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. }
  16. // Update is called once per frame
  17. void Update()
  18. {
  19. transform.RotateAround(rotationPoint.transform.position, rotationAxis, rotationSpeed * Time.deltaTime);
  20. Vector3 newPos = transform.position + (pv.WhalePerpendicular(true).normalized * 2);
  21. transform.LookAt(newPos);
  22. //Debug.DrawRay(transform.position, pv.WhalePerpendicular(false));
  23. }
  24. }