navmesh and A.I car doubts.

I have doubts about the navMesh for AI cars
I do not understand that the new standard assents had been an example of how to use navMesh an AI car. But now no longer well with these examples in version 5.
I do not understand why the navMesh was only created for the use of characters, and not supported for vehicles?
If the navemesh give to use in the vehicle, would like to see a tutorial on how to use the navMesh in vehicles.
I think it would be more valuable to use navMesh in vehicles that use waypoints. at least it is guaranteed that the vehicle runs on different paths of the track.

I hope this help topic to navMesh solution in vehicles and coding.
I don´t know if this is the right place to add this post.

You don't need WheelCollider support for NavMesh, you need to design an AI that looks like a car.

Navmesh doesn't care if its a character, a car, or a space narwhal.

Click to expand...

Yes the navMesh, does not affect anything besides having the navMesh Agent at its bluish way.

I go to try recreate an test scene and simple car and track with 2 paths to start create the logic of the navMesh Agent and simple car A.I follow the agent and steering.
The only question i have is how do i put the navMesh Agent moving in loop in the track. I will see it.

You don't need WheelCollider support for NavMesh, you need to design an AI that looks like a car.

Click to expand...

Not quite. Wheel colliders don't adjust themselves to a NavMesh agent's rotation, nor does the agent's speed and acceleration map directly to a wheel collider's motorTorque, which is why a script is needed to convert the agent's desired velocity into the appropriate wheel angle and motorTorque for a wheel collider. The AI must be designed for a car to follow or chase after a NavMesh agent.

Not quite. Wheel colliders don't adjust themselves to a NavMesh agent's rotation, nor does the agent's speed and acceleration map directly to a wheel collider's motorTorque, which is why a script is needed to convert the agent's desired velocity into the appropriate wheel angle and motorTorque for a wheel collider. The AI must be designed for a car to follow or chase after a NavMesh agent.

Do you mean, a loop, where once it reaches the last point it starts from the beginning point?

Or do you mean a vertical loop?

Click to expand...

Yes, once it reaches the last point it starts from the beginning point, normal tracks racing.

I create an simple unity package, it have simple road and walls , simple car. all made in cinema 4D. the road is navMesh baked. the car have simple player driver controller. ready for play around whit navmesh / agent and vehicle testing.

Attached Files:

I create an simple unity package, it have simple road and walls , simple car. all made in cinema 4D. the road is navMesh baked. the car have simple player driver controller. ready for play around whit navmesh / agent and vehicle testing.

Click to expand...

I'll take a look. Would you have a version of the track that includes waypoint markers, preferably with each waypoint marker having orientation information?

Attached Files:

You want to attach an agent to an AI vehicle, which is aligned to the AI vehicle's position at each update loop (by setting agent's localPosition to (0,0,0) ).

The agent's destination should be each successive waypoint along the track. Once the agent is within a certain distance of a target waypoint, you can set it to the next waypoint (see above code).

The vehicle chases the agent's next position with the velocity vector. The agent's desired Velocity property provides this velocity vector, but it has to be transformed into the AI vehicle's coordinate system, then converted into percentage of torque and wheel Angle.

For avoidance to work obstacles must be able to be carved into the Navmesh.

You want to attach an agent to an AI vehicle, which is aligned to the AI vehicle's position at each update loop (by setting agent's localPosition to (0,0,0) ).

The agent's destination should be each successive waypoint along the track. Once the agent is within a certain distance of a target waypoint, you can set it to the next waypoint (see above code).

The vehicle chases the agent's next position with the velocity vector. The agent's desired Velocity property provides this velocity vector, but it has to be transformed into the AI vehicle's coordinate system, then converted into percentage of torque and wheel Angle.

For avoidance to work obstacles must be able to be carved into the Navmesh.

Click to expand...

tks for the reply. It seen to many logic.

I reached a conclusion that the navMesh and navmesh Agent, was not made for such things as vehicle. Something tells me the Vehicle behavior results is not favorable. I think I'll give up this method.
perhaps a future unity team create a navMesh Agent exclusively for vehicles., perhaps as navMesh Agent Vahicle.
Either way it could be that I'm wrong.

I reached a conclusion that the navMesh and navmesh Agent, was not made for such things as vehicle. Something tells me the Vehicle behavior results is not favorable. I think I'll give up this method.
perhaps a future unity team create a navMesh Agent exclusively for vehicles., perhaps as navMesh Agent Vahicle.
Either way it could be that I'm wrong.

Click to expand...

That's generally correct, Unity's NavMesh system is not well-designed for physics controlled objects interacting with other physics controlled objects. It's better to use ray casts, and have AI vehicles react to obstacles' positions and velocities using ray casts.

That's generally correct, Unity's NavMesh system is not well-designed for physics controlled objects interacting with other physics controlled objects. It's better to use ray casts, and have AI vehicles react to obstacles' positions and velocities using ray casts.

Unity Technologies

You want to attach an agent to an AI vehicle, which is aligned to the AI vehicle's position at each update loop (by setting agent's localPosition to (0,0,0) ).

The agent's destination should be each successive waypoint along the track. Once the agent is within a certain distance of a target waypoint, you can set it to the next waypoint (see above code).

The vehicle chases the agent's next position with the velocity vector. The agent's desired Velocity property provides this velocity vector, but it has to be transformed into the AI vehicle's coordinate system, then converted into percentage of torque and wheel Angle.

For avoidance to work obstacles must be able to be carved into the Navmesh.

Click to expand...

This is exactly the method I used in the video clip mentioned above. You can also set the Agent's acceleration value to zero, meaning that it cannot move itself - but it still has the desiredVelocity property that you can read. It's this "desired velocity" that you can make use of to create any kind of AI pathfinding vehicle or character, when you want to use the pathfinding aspect of the navmesh, but don't want the navmesh agent's style of motion.

I'm currently playing around with this concept and in connection with the Standard Assets AI script I'm using steeringtarget to set my own Waypointtarget object, which seems to do the job in my example scene with 4 cars on the track. Although I'm curious how duck combined the navmeshagent with the waypoint system in the video. Does it just use the waypoints as agent destinations or does it also incorporate other elements like the ProgressTracker.

My biggest problem at this point is that the agents sometimes drive off the track as if there was an invisible roundabout next to the real track. Not sure what's causing that, I suspect it has something to do with the agent coming in contact with a different navmesh-cost-area but not sure.

I'm currently playing around with this concept and in connection with the Standard Assets AI script I'm using steeringtarget to set my own Waypointtarget object, which seems to do the job in my example scene with 4 cars on the track. Although I'm curious how duck combined the navmeshagent with the waypoint system in the video. Does it just use the waypoints as agent destinations or does it also incorporate other elements like the ProgressTracker.

My biggest problem at this point is that the agents sometimes drive off the track as if there was an invisible roundabout next to the real track. Not sure what's causing that, I suspect it has something to do with the agent coming in contact with a different navmesh-cost-area but not sure.

Click to expand...

That is the problem whit the Agent collisions, if you create an combat car racing like , Destruction Derby, Carmaggedom ,Demolition Derby, FlatOut series, WipeOut series etc...
the physics behavior reacts glitchy and bad physics collisions etc....
For that reason i give up continue with this method.

There is an interesting A.I behavior scripting in Carmaggedom OpenC1 C#, an guy recreate an Stainless engine.
probably convert the Opponents A.I behavior scripts to the unity , i don´t know just an idea.

I'm using it for a standard racing game so it should (hopefully) do the trick. Since my last post I tried to visualize the agents desired path and do some debugging on top of it. Turns out that sometimes the object with the navmeshagent wanders off from its origin which caused part of the weird behavior. And sometimes the pathfinding is just a tick too late which gives the car a point that it already has passed and causing it to turn around.

Did you have a look at the Apex path finding system? Depending on the layout of your tracks the grid based system might do the trick for your game

I'm currently playing around with this concept and in connection with the Standard Assets AI script I'm using steeringtarget to set my own Waypointtarget object, which seems to do the job in my example scene with 4 cars on the track. Although I'm curious how duck combined the navmeshagent with the waypoint system in the video. Does it just use the waypoints as agent destinations or does it also incorporate other elements like the ProgressTracker.

My biggest problem at this point is that the agents sometimes drive off the track as if there was an invisible roundabout next to the real track. Not sure what's causing that, I suspect it has something to do with the agent coming in contact with a different navmesh-cost-area but not sure.

Click to expand...

At each update, the NavMesh agent should stay with the origin of the AI vehicle, with the acceleration property set to 0. You'll probably want to create a separate class that sets the agent's destination to each waypoint, and also converts the agent's desired Velocity into acceleration, brake, and torque parameters for CarController.move.

@cl-9 I am trying to process what you mentioned above. Is the script you mentioned above goes into Navmesh agent movement script? I was trying to incorporate the script, but shows "Field `MoveTo.waypoints' is never assigned to, and will always have its default value `null'". Can you help me with it? Thank you.

@cl-9 I am trying to process what you mentioned above. Is the script you mentioned above goes into Navmesh agent movement script? I was trying to incorporate the script, but shows "Field `MoveTo.waypoints' is never assigned to, and will always have its default value `null'". Can you help me with it? Thank you.

Click to expand...

You'll want to populate the waypoints variable using code similar to this: