front-end / back-end: AIMAvoidBounds
| AvoidBounds
inherits from: AIMRadiusSteeringBehaviour
| Avoid
This behaviour is used to actively avoid obstacles. In addition to Avoid, the bounding box information of the perceived object is used.
Similar to Avoid, the tangent plane on the nearest point on the bounding box is used as a basis for the Sensitivity Mapping (writing objective values). A capsule is deduced from the rectangular structure to get smooth tangents when moving around the bounding box. The length of this imaginary capsule can be controlled using the Smoothness
parameter. Figure 1 displays the effect of this parameter. It controls how close the agent can get while moving around the corners. This is more relevant for planar setups than for general 3D scenarios.
When the agent is near the longest edge the plane is created on a cylinder. If next to the corners, the direction is projected on a half-sphere. Using the Smoothness
parameter, it is possible to increase the size of the half-sphere until the whole structure collapses to a sphere. Then, the behaviour is equivalent to AIMAvoid.
Figure 1: Shows the effects of Smoothness
. The yellow capsule has a Smoothness
value of 0. The blue capsule's Smoothness
value is half of the bounding box length (longest side). The red capsule is collapsed to a circle because the Smoothness
value is equal or greater than the box length (longest side).
Similar to AIMAvoid, this behaviour is feasible for general 3D scenarios like the following image shows.
This component has got the following specific properties.
Property | Description |
---|---|
PlaneBend | An angular offset in degrees and within the range of [0, 90]. The offset is applied to the plane such that the optimal direction is shifted towards the obstacle direction. This parameter defines the angle used for avoiding the obstacle. |
Smoothness | Defines how close the agent's trajectory follows bounding box corners. |
UseVelocity | If enabled, the current velocity of the agent is used to emphasize the avoid direction which corresponds to the velocity. Note that the velocity needs to be tracked, which is done automatically if either a SteeringTag or a rigidbody is attached to the agent's game object. |
DefaultOrientation | Can be used instead of the agent's velocity. This direction defines the agent's default alignment. The two most common cases are (0, 1, 0) for 2D games and (0, 0, 1) for 3D games. |
BoundsType | The applied bounding box model: either axis-aligned bounding box (AABB) by collider, oriented bounding box (OBB) by collider or OBB by visual bounds (sprite/mesh). In order for this to work with meshes, a received object must not be static, or otherwise, no visual bounds can be received. For more details, have a look at the bounding box remarks in Planar Avoid Bounds. |
Sensitivity mapping against a plane always leads to a symmetrical magnitude distribution in the context map. An example can be seen in Figure 2. Of course, it makes sense that the agent perceives every possible avoid direction. However, this may lead to problems with certain agent configurations. For example, the agent might jitter back and forth, because it suddenly decides to use the opposite direction which might happen due to numerical inaccuracies. There are some ways to tackle this problem:
UseVelocity
,Another important aspect: The plane gizmo considers only the last updated percept. Hence, it can only be used to visualize the effect of one perceived object at once.
Figure 2: Shows the effect of PlaneBend
. At the left, it is 0° and at the right, it is set to 45°. Due to the nature of plane-based sensitivity mapping, the result is a symmetrical context map. This issue can be avoided by enabling UseVelocity
.