How do I Control AI Steering in Car Behavior?

0 favourites
  • 4 posts
From the Asset Store
Template for a police car chase game, fully documented in comments and video
  • Hi - This topic is diseptively complicated.

    Quick Background: I'm trying to make a top down racer. Specifically I want to explore a 'slot car' concept where the car steers itself and the user is really only controlling the throttle. Too much throttle and the car will drift wide of the turn (something called 'understeer').

    General Approach: I have 'markers' throughout the map that have an instance variable called "GateID". Each car has a "GateID" as well. The car will drive toward the marker with GateID = 1, and when it reaches that, it moves on to GateID =2, etc.

    Steering Approach: I've placed a line on the front of the car (which we'll call "Pointer") that points toward the next Marker. The thought, was that I could control the steering by taking the difference between the Car's Angle, and the Pointer's Angle. So if the car is facing 'up', i.e. 90 degrees, and the Pointer is facing 'right', i.e. 0 degrees, then the car needs to turn right. So then if Car > Pointer, turn right ... right? Not exactly. Using the same example, Car = 90 degrees and Pointer = 360 degrees you would then think you need to turn left because 90 < 360 ... but you still do need to turn right.

    I hope all this makes sense. Has anyone had any luck with this? I just can't seem to make sense of the angles! :(

    Thanks

  • You're looking for the signed angle, which you can then check if it is greater than or less than 0.

    construct.net/en/forum/construct-2/how-do-i-18/angle-difference-directions-87779

  • You're looking for the signed angle, which you can then check if it is greater than or less than 0.

    construct.net/en/forum/construct-2/how-do-i-18/angle-difference-directions-87779

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • create waypoints.... i have a simple AI example somewhere let me look in my drive. (might be missing some comments and weird stuff, but once u understand the logic behind it u can do this in like 5 minutes or less)

    ai example with pitstop (might be a bit complicated but is a simple waypoint controlled by some manually placed dots in screen.

    you can also use the same principle and create for each car "lines" or "raycasting" and basically when car is to close to the walls it turns away from them. it would give u a more realistic feel for the ai cars, but at the expense of CPU usage.

    here is ai barebones mechanics

    hope it helps. is not the raytracing method u where asking...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)