| | | 1 | | using UnityEngine; |
| | | 2 | | |
| | | 3 | | // Ground-based movement. |
| | | 4 | | // |
| | | 5 | | // The agent is confined to only move along the x-z plane. |
| | | 6 | | public class GroundMovement : MovementBase { |
| | 36 | 7 | | public GroundMovement(IAgent agent) : base(agent) {} |
| | | 8 | | |
| | | 9 | | // Determine the agent's actual acceleration input given its intended acceleration input by |
| | | 10 | | // applying physics and other constraints. Ensure that the agent moves along the x-z plane and |
| | | 11 | | // ignore drag and gravity along the ground. |
| | 120 | 12 | | public override Vector3 Act(in Vector3 accelerationInput) { |
| | | 13 | | // Ensure that there is no acceleration out of the x-z plane. |
| | 120 | 14 | | Vector3 constrainedAccelerationInput = accelerationInput; |
| | 120 | 15 | | constrainedAccelerationInput.y = 0; |
| | 120 | 16 | | return LimitAccelerationInput(constrainedAccelerationInput); |
| | 120 | 17 | | } |
| | | 18 | | } |