ID3/Assets/Face.cs
2026-03-19 02:02:28 +03:00

33 lines
772 B
C#

using UnityEngine;
using System.Collections;
public class Face : Align
{
protected GameObject targetAux;
public override void Awake()
{
base.Awake();
targetAux = target;
target = new GameObject();
target.AddComponent<Agent>();
}
void OnDestroy()
{
Destroy(target);
}
public override Steering GetSteering()
{
Vector3 direction = targetAux.transform.position - transform.position;
if (direction.magnitude > 0.0f)
{
float targetOrientation = Mathf.Atan2(direction.x, direction.z);
targetOrientation *= Mathf.Rad2Deg;
target.GetComponent<Agent>().orientation = targetOrientation;
}
return base.GetSteering();
}
}