Apply throttle and/or brakes to vehicle based on angle to next target location using NavMesh.


Am currently working on a racing game project that is using a NavMesh as a race track for AI agents. Currently the blueprint is set up so the AI is able to drive on the race track using the NavMesh and reach a set end point. The AI can currently apply its own steering in order to reach a set point automatically generated through using the node ‘Find Path to Location Synchronously’. The AI is a child blueprint of the Unreal Engine’s vehicle movement template, therefore it uses the Vehicle Movement Component to drive itself. The AI’s throttle input is currently being set manually in the blueprint itself by me.

Basically, I want the AI to decide how much throttle to give in order to reach the next designated point on the track. This variable needs to be dynamic and change depending on the current location of the AI car. It needs to decide whether to add more or less throttle to reach the designated location depending on the angle of steering it needs.

I have already worked out the angle between the car and the next set point on the track but I have no clue on how to work out the math for the throttle input. I would also like to add a brake input to this to slow the car down if its travelling too fast. I understand what needs to be done but have no clue how to do it! Thank you for anyone who can give me any tips!