Custom Vehicle Controller
  • Custom Vehicle Controller
  • Guides
    • Workflow
      • Quick Setup
      • Creating New Parts
      • Modifying Parts
      • Creating Vehicle Parts Presets
      • Customizable Sets and Runtime Parts Change
      • Engine Performance Customization
      • Exposing Current Car Stats
    • API
      • CustomVehicleController
      • VehicleEngineSoundManager
      • RaceManager
      • RacerProgress
      • RaceSpawner
      • CollisionHandler
    • Vehicle Controller Input Provider
      • Input System Example
      • Mobile Input
    • Tips, Warnings and Requiremens
      • Work With Editor
      • Vehicle Set Up
    • AI Setup
      • AI Racer Creation
      • AI Racer Setup
      • AI Chaser Setup
      • Race Creation
      • Race Configuration
      • Race Information
    • Vehicle Damage System
      • Vehicle Damage Controller
      • Collision Area Partitioner
      • Part Damage Handler
      • Vehicle Attachments Aligner
      • Collision Handler
    • Additional Settings
      • Custom Vehicle Controller
      • Car Visuals Essentials
    • Package Settings
      • Assets Save Location
      • Project-Wide Surface Settings
    • Extra
      • Adding Visual Effects
        • Individual Effect Set Up
      • Adding Sound Effects
        • Adding Engine Sound
        • Adding Extra Sound Effects
  • Converting To Other Render Pipelines
    • Convert To Built-in RenderPipeline
    • Convert To HDRP RenderPipeline
Powered by GitBook
On this page
  1. Guides
  2. AI Setup

AI Racer Setup

PreviousAI Racer CreationNextAI Chaser Setup

Last updated 1 year ago

An important step in creating a functional AI is making sure it receives all the information it needs.

Add the "Raycast Sensor Debugger" component. This component will display what information the AI will receive.

Add the reference to the "Raycast Sensor" component:

Enable Gizmos and modify the properties to your needs:

You can think of these rays as a field of view of the AI. The range of the decisions an AI can make depends on the number and angle between the rays, so make sure the overall angle between left and rightmost rays is big enough.

Rear Ray Length should be just a little behind the car so that the AI knows it can't go in that direction.

Next, create a new layer and assign it to potential obstacles the AI must know of. Create "Obstacle" and "Vehicle" layers.

Assign the "Vehicle Layer" to the game object with the collider on the vehicle.

Assign the "Obstacle" layer to any stationary object that the AI must know of.

In the "Raycast Sensor" component, add the recently created layer to the "Collision Layer" property:

To configure the racer's behavior you can modify the following properties:

Property
Description

AI Interest Modifier

Defines how close the car wants to stay to the track. Higher values reduce the interest of going into any direction except the closest one. Very high values can cause the vehicle to ignore possible collisions.

AI Danger Modifier

Defines how dangerous the AI will treat the collisions that are not in its way. Higher values reduce the danger of possible side collisions

Riskiness

Defines how close the possible collision must be for AI to take extreme action to avoid it. Danger is defined as a dot product between the vehicle's forward axis and the danger direction. If dot product is higher than risk, the AI will brake and steer away from danger