Polarith AI
1.8
Seek Ground

This script works together with a Radius Steering Behaviour like Seek and Flee. You can either add danger in direction of the ground if you use Seek, or you can add interest in direction away from the ground if you use Flee. The script performs a raycast to obtain hits against colliders of the underlying environment. The inner and outer radii of the attached Radius Steering Behaviour are used to improve the raycast by preventing self-intersections (inner radius) and to limit the distance to the ground (outer radius). If there is no hit, the last hit point is used. To get better values in the direction of movement, we predict the position of the agent. Therefore, we use the rigidbody's velocity and the DecidedDirection to compute its position in the next seconds based on the PredictionTime and perform the raycast in direction of (0,-1,0). Note that we will only get useful results if the y-axis points upwards. You can see the influence of PredictionTime in Figure 1.

Figure 1: Shows the influence of PredictionTime. If PredictionTime is equal to 0, the raycast is performed orthogonal to the ground, i.e., directly under the agent. If PredictionTime is greater than 0, the position of the agent is predicted based on its velocity in the decided direction.

Properties

This script has got the following specific properties.

Property Description
PredictionTime Time in seconds to compute the agent's position in the DecidedDirection
Body Reference to the rigidbody of the agent to predict its position.
RadiusSteering Reference to AIMRadiusSteeringBehaviour component to generate interest or danger.
EnableGizmos Enables or disables the visualization of the raycast.

Preview

Imprint