Tower_Head.cs 513 B

123456789101112131415161718192021
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Tower_Head : MonoBehaviour {
  5. EnemyMovement target = null;
  6. void Start () {
  7. }
  8. // Update is called once per frame
  9. void Update () {
  10. target = GetComponentInParent<Tower>().finalTarget;
  11. if (target != null)
  12. {
  13. Vector3 targetpos = target.transform.position;
  14. transform.LookAt(new Vector3(targetpos.x, transform.position.y, targetpos.z));
  15. }
  16. }
  17. }