Platformer example started
This commit is contained in:
1 parent
efcfaae647
commit
9f026b76d6
325 files changed
+23540
-270
No files matched your search
@@ -10,7 +10,7 @@ namespace Code.Example.Race.Racer.AI.ID.Behaviours
|
||||
|
||||
steering.linear = transform.position - target.position;
|
||||
steering.linear.Normalize();
|
||||
steering.linear *= agent.Data.maxAcceleration;
|
||||
// steering.linear *= agent.Data.maxAcceleration;
|
||||
return steering;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3a071d2cab443528dd16bdc044bab65
|
||||
timeCreated: 1770998212
|
||||
@@ -11,8 +11,7 @@ namespace Code.Example.Race.Racer.AI.ID.Behaviours
|
||||
steering.linear = target.position - transform.position;
|
||||
UnityEngine.Debug.DrawRay(transform.position, steering.linear, Color.yellow, 5f);
|
||||
// steering.linear *= agent.Data.maxAcceleration;
|
||||
steering.linear.Normalize();
|
||||
UnityEngine.Debug.Log(steering.linear);
|
||||
steering.linear.Normalize();
|
||||
return steering;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user