A system of vehicles that interact with each other

I am trying to make a racing game for mobiles where vehicles will interact with each other like they will hit when they find the other vehicle in their neighbor or will cross them but the issue is AI is not supported in vehicles so i have not any idea how to start it. It would be very helpful for me if you give some ideas how to start such a system.

I believe that the vehicle should only have the commands (accel, break, reverse, turn etc) and the controller should access it’s functions, in that case I believe you should create your controller to use the vehicle commands to folow a path or direction and set the AI to generate this path/direction.

Thanks for you reply @lotti. Can you explain a bit more please?

ok, here, take a look on these:

That's a simple vehicle movement using navmesh.

For racing ones with streets and such, using spline follow path might suits you better:

it doesn't have sound but you can undestand what should be done.

Thanks for the links. But dont you think if I uses spline for the movements of cars it will look so much deterministic and hard coded?

Splines are better for raceway, also there is some other things you might consider, like reduce speed before turning or avoid collision against other cars.
But for open scenes, using navemesh will suits better.

and what about the interaction logic? how will they interact with each other? like hitting the nearest vehicle for example.

Events like that could be triggered by raycasts with a limited distance that happen every now and then. Overlap events might be a little expensive to program such behavior.

E.g.:

-Car 1 is behind Car 2

-Car 1 does a raycast to front, left and right

-Car 1 get a hit result for the front

-Car 1 accelerates in order to hit Car 2

This shouldn’t always happen of course, otherwise you’d pretty much have a new Burnout title :slight_smile:
You could also program aggressive behavior in the nav mesh (straight road = higher raycast intervals)

thanks. But what do you think about the AI, as you know AI is not supported in vehicles. Cant I use the third person default blueprint and replace the dummy character with vehicle using this I can also use the AI logics that is pre-built .

AI should be placed on controller, which can be done even on cars too (need a little work on that)

And for that case, you can use AIPerception for that, and navmesh to make your vehicle move…