TestAngle.cs 533 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class TestAngle : MonoBehaviour
  5. {
  6. public Transform target;
  7. public Transform thiss;
  8. private void Update()
  9. {
  10. Vector3 target_pos = target.position;
  11. Vector3 my_pos = thiss.transform.position;
  12. Vector3 from = Vector3.forward;
  13. Vector3 to = target_pos - my_pos;
  14. Quaternion rot = Quaternion.FromToRotation(from, to);
  15. ; thiss.transform.rotation = rot;
  16. }
  17. }