RiftMayhem/Assets/Scripts/NPCProjectileSpawnLocationController.cs
2025-02-21 18:35:51 +00:00

36 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NPCProjectileSpawnLocationController : ProjectileSpawnLocationController
{
NPCController npcController;
NPCControllerBase npcControllerBase;
protected override void Awake()
{
npcController = GetComponentInParent<NPCController>();
npcControllerBase = GetComponentInParent<NPCControllerBase>();
}
// Update is called once per frame
protected override void Update()
{
if(npcController == null)
{
if (npcControllerBase.currentTarget == null) return;
targetPoint = npcControllerBase.currentTarget.transform.position;
targetPoint.y = this.transform.position.y;
lookAt.forward = targetPoint - lookAt.position;
}
else
{
if (npcController.currentTarget == null) return;
targetPoint = npcController.currentTarget.transform.position;
targetPoint.y = this.transform.position.y;
lookAt.forward = targetPoint - lookAt.position;
}
}
}