lab3
This commit is contained in:
1 parent
a70076ebe9
commit
854835878c
20 files changed
+2542
No files matched your search
@@ -0,0 +1,35 @@
|
||||
using Code.Base;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Lab3
|
||||
{
|
||||
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()
|
||||
{
|
||||
var direction = TargetAux.transform.position - transform.position;
|
||||
|
||||
if (direction.magnitude <= 0) return base.GetSteering();
|
||||
|
||||
var targetOrientation = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
|
||||
target.GetComponent<Agent>().orientation = targetOrientation;
|
||||
|
||||
return base.GetSteering();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user