The Steering System in the Untold Engine enables entities to move dynamically and intelligently within the scene. It provides both low-level steering behaviors (e.g., seek, flee, arrive) for granular control and high-level behaviors (e.g., steerTo, steerAway, followPath) that integrate seamlessly with the Physics System.
The Steering System is essential for creating dynamic and realistic movement for entities, such as:
- A character chasing a target.
- An enemy avoiding obstacles.
- A vehicle following a predefined path.
The high-level behaviors are recommended because they are designed to work closely with the Physics System, simplifying implementation while maintaining smooth motion.
Examples:
- Steer Toward a Target Position:
steerTo(entityId: entity, targetPosition: targetPosition, maxSpeed: 5.0, deltaTime: 0.016)
- Steer Away from a Threat:
steerAway(entityId: entity, threatPosition: threatPosition, maxSpeed: 5.0, deltaTime: 0.016)
- Follow a Path: Guide an entity along a series of waypoints.
followPath(entityId: entity, path: waypoints, maxSpeed: 5.0, deltaTime: 0.016)
- Pursue a Moving Target:
steerPursuit(entityId: chaserEntity, targetEntity: targetEntity, maxSpeed: 5.0, deltaTime: 0.016)
- Avoid Obstacles:
avoidObstacles(entityId: entity, obstacles: obstacleEntities, avoidanceRadius: 2.0, maxSpeed: 5.0, deltaTime: 0.016)
- Low-Level Behaviors:
- Calculate desired velocity based on the target or threat position.
- Generate steering forces by comparing desired velocity with current velocity.
- High-Level Behaviors:
- Use low-level behaviors to calculate steering adjustments.
- Apply these forces to the entity’s physics system for smooth, realistic motion.
- Align the entity’s orientation to face its movement direction.
- Physics Integration:
- Forces are applied through the Physics System, ensuring that movement respects mass, velocity, and acceleration.
- Prefer High-Level Behaviors: They simplify complex movement patterns and automatically handle integration with the Physics System.
- Use Low-Level Behaviors for Custom Logic: When precise control is required, combine low-level behaviors for unique movement styles.
- Smooth Orientation: Use alignOrientation or integrate orientation alignment directly into high-level functions.
- Tune Parameters: Adjust maxSpeed, turnSpeed, and slowingRadius for different entity types (e.g., fast-moving cars vs. slow-moving enemies).
- Cause: The Physics Component is missing or paused.
- Solution: Ensure the entity has a PhysicsComponents and it’s not paused.
- Cause: Conflicting forces or large delta times.
- Solution: Tune maxSpeed and ensure deltaTime is passed correctly.
- Cause: Avoidance radius is too small or obstacles are not registered.
- Solution: Increase the avoidanceRadius and verify obstacle entities.