Below is a comprehensive documentation for the ContextSteering script. You can use this documentation as a reference to understand its purpose, configuration, and inner workings.


Overview

The ContextSteering script is a Unity MonoBehaviour component designed for vehicle AI. It implements a context-based steering system that helps a vehicle determine the best steering direction by evaluating multiple potential directions. This evaluation considers the target direction, obstacles, and the presence of other vehicles. The script uses sphere casts to detect obstacles and dynamically calculates “interest” (how much a given direction aligns with the goal) and “danger” (how much an obstacle or other vehicle interferes with that direction). It then combines these factors to decide on an optimal steering direction.


Key Features


Setup and Configuration

  1. Adding Context based Steering Script :

    You can add this script by right clicking on Ai Vehicle Controller Script and selecting Add Context based Steering Option. (you can also remove it using Remove Context Based Steering Option)

  2. Steering Settings:

  3. Weights:

    Adjust the following weights to balance between reaching the target and avoiding hazards:

  4. Vehicle Dimensions and Obstacle Settings:

  5. Gizmo Settings:

    Enable or disable gizmo visualizations such as interest levels, danger levels, and the best direction for debugging purposes.