Multi-Lane Navigation
AI racers are capable of switching between multiple lanes along a spline-based track, allowing for more realistic and strategic movement.
Path Decision Logic
When an AI collides with a designated spline trigger box, it:
Loops through available path options
Randomly selects a valid path to follow
Ensures variation in racer behavior across laps
Steering and Speed Calculation
Each AI racer dynamically adjusts:
Steering direction based on target lane
Speed to match curvature and lane changes
Lane Bound Detection
The system calculates the maximum allowed lane width for each AI:
Uses a tangent vector from the AI position to the spline center
Computes lane width based on spline radius at that segment
Prevents AI from steering outside valid bounds
Steering Calculation
Get Current Path and calculate tangent position along the path
Determine which side the AI racer wants to be on based on displacement along the path
Based on position along spline, calculate the speed the AI should be going
Forward Box Cast
Each AI racer performs a forward-facing box cast to detect potential collisions with track obstacles or other racers.
Impact Feedback
Green: no collision detected
Red: collision detected
This visualization helps debug avoidance decisions in real time.
Collision Analysis
On impact:
The system stores both the impact point and the impact normal
A direction vector from the AI to the impact point is calculated
Side Detection via Cross Product
Using the cross product between the AI’s forward vector and the impact direction, the system determines whether the obstacle is on the left or right side.
Smooth Steering via Interpolation
Based on the side, the AI smoothly steers away from the obstacle over time using interpolation for natural motion.
Reflection Vector Steering
A reflection vector is calculated using the actor’s forward vector and the impact normal. This vector is used to determine an alternate safe direction.
Dynamic Road Positioning
The reflection direction helps decide which side of the road the AI should steer toward, ensuring consistent avoidance behavior across varied track layouts.
Box Cast to detected an object in front of the AI
Steering Recalculation for AI if there's and obstacle in the direction it's currently steering towards
Context-Aware Item Logic
AI racers use items strategically, not randomly. Each item type has specific conditions that must be met before activation.
Item-Specific Behaviors
The logic differs depending on the item:
Offensive items (e.g., water balloons) are saved for moments when an opponent is in sight or within range.
Defensive items (e.g., shields) are used reactively when threats are detected nearby.
Avoids Wasteful Item Use
AI avoids using items in ineffective situations (e.g., firing a water balloon when not when a certain range to hit an opponent or using a shield immediately upon item grab).
Logic for how and when the AI should use an item if it has that specific item
Logic that the AI has for determining when to use the water balloon if it has that item