Although the Navmesh works properly at low speeds. The car needs to be sped up to look more realistic.
When the speed is increased, the car appears to be travelling to fast to turn (Physically and Visually) to follow the road properly. Instead it slams into the wall.
I have recorded a 90Second Video to demonstrate the issue.
Try tweaking the Angular Speed variable on the NavMeshAgent, I find that this needs to be quite high(500 for me) for the wandering people in my scenes to turn efficiently.
This value would likely need to be affected by the forward speed the car is travelling (as a cars turning circle is larger at higher speeds).
I haven’t checked this since my bots all use a consistent Angular Speed, but it’s the first thing I would check.
Unfortunately even ramping the angular speed up to 1,000,000 still had no effect. Just cant get it turn appropriately… I am thinking I might need to add multiple waypoints on top of the navmesh, rather than simple “Checkpoints”
It could be something to do with the geometry of the mesh used for the NavMesh, but I’d find that a bit odd.
It’s probably worth noting that even if this system did work correctly it isn’t going to work very well in terms of cars following the racing line, the Agents aren’t that clever.
So it could be worth looking at something like this: Steering Behaviors For Autonomous Characters
Or looking at existing racing AI assets to see how they have implemented their systems: 伟德国际victor1946|NO.1
That doesn’t solve the problem of the Agents not turning though, perhaps more waypoints may help smooth out the problem as you say.
Thanks again, Unfortunately the multiple waypoints does improve the situation, but still has issues.
If I could somehow figure out what the parameter is to reduce its velocity/force I would be all set… but no luck as the Unity Documentation is empty on the topic.
I have actually completed a Racing Game for Unity about a year ago and imo using Unity’s standard NavMesh/NavAgent stuff just isn’t going to do it for you, not by a long shot. I had to write a completely custom system to control my AI cars. The problem is that the cars are going so fast - and can sometimes be quite tightly grouped in a small space - that your AI cars just need to know a lot more about the track ahead and the other AI cars around it.
In my system I used race lines to pull a “Rabbit” around the track which the AI cars then tried to follow a closely as possible. The race line nodes also store lots of information about the track, things such as how fast the AI car should ideally be going when approaching a certain bend in the track. Because the speed is usually so fast, you are going to want your AI cars to be able to “read ahead” so they know what is coming in plenty of time to react (be that a simple deceleration, lane change or to avoid an obstacle). Also, assigning a Nav Agent just isn’t going to make the car react in a realistic way. So at the very least you will probably need a system of race lines on your track (there are other ways but this is probably the simplest and gets good results), along with dedicated Car AI scripts and dedicated vehicle scripts assigned to each car as well.
Its actually pretty challenging to get right and come up with a system that can handle all situations on various types of race track. I found the A.I portion of the project probably the trickiest to get right.
Thanks for that, navmesh would have been great if it could have done it, Race Lines it is. Race Lines would be done with a simple waypoint system as a guess?
Hey this is perhaps a bit late to respond. But I had the same issue. In my project, the issue wasn’t how fast the navagent actually turns, but just the rotation from a visual/aesthetics perspective. So, I thought I would share my neat solution, take direct control away form the navmesh agent, and set the transform using navmesh data:
float speed = 10f; //however fast you want the rotation;