lab3
This commit is contained in:
1 parent
a70076ebe9
commit
854835878c
20 files changed
+2542
No files matched your search
@@ -0,0 +1,39 @@
|
||||
using Code.Base;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Lab3
|
||||
{
|
||||
public class Wander : Face
|
||||
{
|
||||
public float offset;
|
||||
public float radius;
|
||||
public float rate;
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
target = new GameObject
|
||||
{
|
||||
transform =
|
||||
{
|
||||
position = transform.position
|
||||
}
|
||||
};
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
public override Steering GetSteering()
|
||||
{
|
||||
var wanderOrientation = Random.Range(-1f, 1f) * rate;
|
||||
var targetOrientation = wanderOrientation + Agent.orientation;
|
||||
var orientationVec = GetOriAsVec(Agent.orientation);
|
||||
var targetPosition = offset * orientationVec + transform.position;
|
||||
targetPosition += GetOriAsVec(targetOrientation) * radius;
|
||||
TargetAux.transform.position = targetPosition;
|
||||
var steering = base.GetSteering();
|
||||
steering.Linear = TargetAux.transform.position - transform.position;
|
||||
steering.Linear.Normalize();
|
||||
steering.Linear *= Agent.maxAcceleration;
|
||||
return steering;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user