Announcement

Collapse
No announcement yet.

How to make AI Catch-Up/Rubberband ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to make AI Catch-Up/Rubberband ?

    Hello everyone,

    I want to make AI Catch-Up/Rubberband for a racing game, but I don't know how to do it. I am not looking for code samples/screenshots etc. I want to know what is the logic behind it. Which tools should be useful to create? Is it based on splines? etc. Everything related to it will be helpful.

    #2
    yeah, you could use splines or checkpoints. a spline would probably be a bit easier to tweak.

    basically add a spline across the track and periodically have the ai see what place they are in by referencing their distance along the spline. if they are doing laps then you'd have to add an int variable to the cars to count laps.

    (current distance on spline*current lap)/ (spline length*Total Laps) = percentage of race completed

    then have each car ai compare the the percentage of whoever is in first with their own position and give them some extra speed based on that.


    https://answers.unrealengine.com/que...-location.html



    Splines could get pretty complex if you have a track with a bunch of branches paths since you'd have to use multiple splines. So long as any branches on the racetrack are generally going in the same direction though you can just put the spline in the average location and it should would reasonably well.

    you could give cars a boost based on the distance behind the players in the lead instead of the percentage, might be easier to work with if you have a bunch of different track sizes. you could also project the estimated time it will take the ai to finish the course so if the human finishes all the ai times can be filled in right away without having the player wait for em.
    Last edited by IndieGameCove; 09-29-2019, 02:17 PM.
    YT Channel: https://www.youtube.com/channel/UCoc...KYPSK6g7vZ5CNg

    Comment


      #3
      You could use something that measures the distance between you and the AI and get the dot product to the destination ( to make sure they are not ahead of you ) and then scale their speed based on that.

      Comment

      Working...
      X