Platformer example started
This commit is contained in:
1 parent
efcfaae647
commit
9f026b76d6
325 files changed
+23540
-270
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Code.Example.Race.Racer.AI.ID.Behaviours
|
||||
{
|
||||
|
||||
public class Pursue : Seek
|
||||
{
|
||||
public float maxPrediction;
|
||||
private GameObject _targetAux;
|
||||
private GameObject _target;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_targetAux = _target;
|
||||
_target = new GameObject();
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
Destroy(_targetAux);
|
||||
}
|
||||
|
||||
public override Steering GetSteering(Transform targetTransform)
|
||||
{
|
||||
var direction = _targetAux.transform.position - transform.position;
|
||||
var distance = direction.magnitude;
|
||||
var speed = agent.CarRigidbody.linearVelocity.magnitude;
|
||||
float prediction;
|
||||
|
||||
if (speed <= distance / maxPrediction)
|
||||
prediction = maxPrediction;
|
||||
else
|
||||
prediction = distance / speed;
|
||||
|
||||
_target.transform.position = _targetAux.transform.position;
|
||||
// _target.transform.position += targetAgent.velocity * prediction;
|
||||
|
||||
return base.GetSteering(_target.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user