Posted February 12, 2023 by GameSalutes
This update continues to focus on the AI of the game. This time we shift focus back to the traffic NPCs.
As we can see from the footage above, the traffic vehicle is moving along the waypoints set up by the spline movement system. Using the existing perception system integration, it sees a line of cars ahead. It computes the average speed of those cars relative to its current speed and based on a threshold decides that it is best to change lanes to go around. In this case the cars are not moving so the check obviously passes. When determining if a lane change is viable, it is scanning the cars that exist up ahead in that lane. If there were cars in its direct path then the lane change check would fail, and the car would be forced to stop. In this case though the lane is clear so it picks the adjacent lane and starts moving along it. In order to make a smooth transition, the distance up ahead is configured to be several car lengths (currently 10) as that experimentally resulted in a smooth transition.
In above image, we can see that the blue hatchback car is approaching the player on opposite side of road and wants to make a left turn. It detects that the player is heading toward it in an oncoming lane at a speed that will prevent that car from being able to clear the turn without a collision or impeding the oncoming car. The blue car decides it is best to stop and wait for the car to pass before continuing on its turn. We can see from the image though that the blue car is violating a best practice of keeping the wheels straight before starting a turn. This wheels turning issue can be fixed in a future update.