scripts 1 var
This commit is contained in:
1 parent
6df424ea8e
commit
1798ac3fc5
10 files changed
+364
No files matched your search
@@ -0,0 +1,32 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user