AI Capture Mechanic
This commit is contained in:
parent
544716547e
commit
ecd1efee56
|
@ -25,15 +25,19 @@ public class AIPrototype : Script
|
|||
|
||||
[SerializeField]
|
||||
[Tooltip("How fast the object moves about waypoints")]
|
||||
private float patrolSpeed = 1.0f;
|
||||
private float patrolSpeed = 0.4f;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("How fast the object moves while chasing")]
|
||||
private float chaseSpeed = 1.5f;
|
||||
private float chaseSpeed = 0.8f;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("How near the player must be to the AI for capture")]
|
||||
private float distanceToCapture = 1.2f;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("How near the player must be for the chase to begin. Should be less than distanceToEndChase")]
|
||||
private float distanceToStartChase = 1.5f;
|
||||
private float distanceToStartChase = 2.0f;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("How far the player must be for the chase to end. Should be greater than distanceToStartChase")]
|
||||
|
@ -151,6 +155,12 @@ public class AIPrototype : Script
|
|||
//TODO delete this when original intended code above works with velocity being limited correctly
|
||||
rb.LinearVelocity = normalisedDifference * chaseSpeed;
|
||||
|
||||
//Capture player if near enough
|
||||
if ((pTransform.GlobalPosition - transform.GlobalPosition).GetMagnitude() <= distanceToCapture)
|
||||
{
|
||||
player.GetValueOrDefault().GetScript<PlayerController>().currentState = PlayerController.RaccoonStates.CAUGHT;
|
||||
}
|
||||
|
||||
//End chase if too far
|
||||
if ((pTransform.GlobalPosition - transform.GlobalPosition).GetMagnitude() >= distanceToEndChase)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue