void FixedUpdate()
    {
        var targetPosition = _enemy.PathFollower.transform.position + _enemy.PathFollower.offsetTranslation;

        var steeringForce = Arrive.Calculate(transform.position, _enemy.Rigidbody.velocity, targetPosition, MaxSpeed);

        _enemy.Rigidbody.AddForce(steeringForce, ForceMode.Acceleration);
    }
Example #2
0
 public static Vector3 Calculate(
     Rigidbody rigidbody,
     Transform transformOne,
     Transform transformTwo,
     float maxSpeed = 1
     )
 {
     return(Arrive.Calculate(
                rigidbody.position,
                rigidbody.velocity,
                (transformOne.position + transformTwo.position) / 2,
                maxSpeed
                ));
 }
Example #3
0
    public static Vector3 Calculate(Steering instance, Deceleration deceleration, float decelerationRate)
    {
        if (instance.path == null)
        {
            return(Vector3.zero);
        }

        instance.path.Update(instance.Owner.Position);

        if (!instance.path.IsFinished)
        {
            return(Seek.Calculate(instance, instance.path.Current));
        }
        else
        {
            return(Arrive.Calculate(instance, instance.path.Current, deceleration, decelerationRate));
        }
    }