SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
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.

19 lines
583 B

4 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Follow : MonoBehaviour
  5. {
  6. [SerializeField]
  7. private Transform target;
  8. // Start is called before the first frame update
  9. // Update is called once per frame
  10. void Update()
  11. {
  12. Vector3 lookPos = target.position - transform.position;
  13. Quaternion lookRot = Quaternion.LookRotation(lookPos, Vector3.up);
  14. float eulerY = lookRot.eulerAngles.y;
  15. Quaternion rotation = Quaternion.Euler(0, eulerY, 0);
  16. transform.rotation = rotation;
  17. }
  18. }