Full notes
Full City-Racing update
Read the full published notes in a cleaner layout. The original post stays linked below.
What changed
- Gameplay
- Performance
City-Racing changes
What was added:
·Lane center calculation based on waypoint and lane width.
·Lane detection for the AI car.
·Lookahead logic for all 4 lanes.
·Example lane selection and steering target.
·Optional debug visualization.
This will make your AI cars aware of all lanes and able to select the best one based on traffic ahead. Let me know if you want this integrated with your actual steering logic or need further customization! Did we not add the actual steering logic? I thought it was working already! Please code this function so the AI Cars know and use the empty lanes to drive better.
What Was Added
· Lane Center Calculation:
· The system now calculates the world positions of all 4 lane centers at each waypoint, based on the waypoint’s position and the road’s width.
· Lane Detection for AI Cars:
· Each AI car determines which lane it is currently closest to, so it knows its position relative to all lanes.
· Lookahead Logic for All Lanes:
· The AI checks ahead in all 4 lanes using raycasts to detect obstacles (like other cars or traffic) for a configurable distance.
· Active Lane Selection and Steering:
· The AI prefers to stay in its current lane, but if that lane is blocked, it will automatically select the nearest open lane.
· The AI then steers toward the center of the selected lane, using a proportional steering calculation.
· Debug Visualization (Optional):
· Visual debug lines and rays show lane centers, lookahead checks, and the chosen lane in the Scene view for easy tuning and troubleshooting.
---
How It Works Now
· Every frame, the AI car:
Determines the next waypoint and calculates the positions of all 4 lane centers at that waypoint.
Checks which lane it is currently in.
Looks ahead in each lane to see if there are any obstacles (using the specified layer mask).
If its current lane is blocked, it finds the nearest open lane (left or right).
Steers toward the center of the best open lane, ensuring smooth and intelligent lane changes.
(Optionally) Draws debug lines for visual feedback in the editor.
---
Why It’s Better Than Before
· Traffic Awareness: The AI no longer blindly follows the center of the road or the waypoints. It actively checks for traffic and obstacles in all lanes.
· Dynamic Lane Changing: If a lane is blocked, the AI can switch to an open lane, reducing crashes and traffic jams.
· Realistic Driving: The AI mimics real-world driving by staying in its lane when possible and only changing lanes when necessary.
· Customizable and Visual: Lane width, lookahead distance, and obstacle detection are all configurable. Debug visualization helps you see and tune the system.
· Scalable: Works for any number of AI cars and adapts to different road layouts as long as waypoints are in the road center.
---
In summary: Your AI cars are now much smarter, safer, and more realistic in city traffic. They can avoid blocked lanes, reduce collisions, and make better driving decisions—making your city racing game more fun and believable!
Source
Changelog.gg summarizes and formats this update. How we read updates.
