Added FaceTarget method
This commit is contained in:
parent
74a95468a5
commit
79127c8dac
|
@ -75,6 +75,7 @@ public class EnemyAI : MonoBehaviour
|
||||||
private void AttackTarget()
|
private void AttackTarget()
|
||||||
{
|
{
|
||||||
_animator.SetBool(AttackAnimation, true);
|
_animator.SetBool(AttackAnimation, true);
|
||||||
|
FaceTarget();
|
||||||
//print("Die Human!");
|
//print("Die Human!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +94,13 @@ public class EnemyAI : MonoBehaviour
|
||||||
return Vector3.Distance(gameObject.transform.position, targetPosition);
|
return Vector3.Distance(gameObject.transform.position, targetPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FaceTarget()
|
||||||
|
{
|
||||||
|
Vector3 direction = (_target.position - transform.position).normalized;
|
||||||
|
Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z));
|
||||||
|
transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * _rotationSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
void OnDrawGizmosSelected()
|
void OnDrawGizmosSelected()
|
||||||
{
|
{
|
||||||
Gizmos.color = Color.red;
|
Gizmos.color = Color.red;
|
||||||
|
|
Loading…
Reference in New Issue