Even better car driving game AI!

Поділитися
Вставка
  • Опубліковано 29 січ 2025

КОМЕНТАРІ • 14

  • @physbuzz
    @physbuzz 5 місяців тому +1

    Nice! Thank you for showing the code snippets too, I'm currently writing some AI for a (very tiny) hobby project and it's a good reminder to not overcomplicate things / that simple state machines are perfectly fine.

    • @MadrigalGames
      @MadrigalGames  5 місяців тому +1

      Absolutely! The older I get the less I feel the need to write "clever" code, favoring dead-simple stuff instead. Many times it ends up being more performant too...

  • @117iwhbyd7
    @117iwhbyd7 5 місяців тому +1

    @Madrigal, I can't believe how good these AI vehicle mechanics are.
    The pathfinding at 9:58 is unlike anything I have ever seen.
    I tried to implement my own AI vehicle pathfinding system a while back in Unreal, but it was a disaster.
    Is there any design approach that you would recommend when approaching an issue like this?
    Are there any resources that you could point me in the direction of?
    I would love to know more!

    • @MadrigalGames
      @MadrigalGames  5 місяців тому +1

      Thank you! Yeah, it's coming together quite nicely. Honestly, most of this is stuff I have come up with myself, as I wasn't able to find much info on suitable vehicle AI online either. I basically started small and tried to identify issues with the approach, and then tried to solve them one after another. That's why the driving AI has a bunch of sub-systems, many of which tackle one particular issue or case, as you might be able to see in the code section at the end of the video.
      Is there anything in particular you struggled with? I don't know how Unreal expects/wants you to set things up, but describing the whole system is obviously too large of a thing to do in a YT comment. Maybe I could dedicate a video going through the AI code, if there is enough interest. I've also toyed with the idea of open-sourcing parts of the game code, and AI could be one such part. Obviously it wouldn't build without the rest of the code and engine, but it might be of interest to other people as a reference.
      Finally, I know that Mercuna (mercuna.com/ground-navigation/) has some middleware which is supposed to handle driving AI quite well, in UE5.

  • @mostrealtutu
    @mostrealtutu 5 місяців тому

    welcome back

  • @StevenHokins
    @StevenHokins 5 місяців тому

    Looks really good, thank you for video update

  • @chiefcloudyeye0489
    @chiefcloudyeye0489 5 місяців тому

    is it intentional that the prediction doesn't actually line up with where it would go if it continued at the same turning radius?
    I could see where it would be as having it offset like that makes for earlier detection of obstacles

    • @MadrigalGames
      @MadrigalGames  5 місяців тому

      Yeah, this is comes from the local offset applied to the predictor, and it's especially noticeable with the Mother vehicle. You can see the offsets in the AI profile JSON data at around 11:30, at the bottom, where the mother vehicle pushes the detection forward and backward. If you don't offset it at all it lines up with the transform of the vehicle, but then most of the points will be inside the vehicle and of no real use. On the other hand, predicting far into the future tends to be unreliable. I've toyed with the idea of offsetting left/right or perhaps rotating the predictor based on steering value or angular velocity, but we'll see if that is necessary.

    • @chiefcloudyeye0489
      @chiefcloudyeye0489 5 місяців тому

      @@MadrigalGames why not keep your current offset system but do your prediction after the offset instead of before?
      right now you have a predicted path of what seems to be the center but offset to the front,
      what if you instead had a predicted path of the offset position?
      immediate problems / differences would be that
      the points could become significantly further apart when large vehicles are turning,
      and the predicted path would be more accurate to the real path than it is currently, which the looseness of your current system may be helping the pathfinding as it rejects dangerous paths faster by overshooting turns

    • @MadrigalGames
      @MadrigalGames  5 місяців тому

      Your initial comment got me thinking. What I might want to do is have a set of offsets, per AI profile, eg. center, left and right, specified in local space. These would represent the front/back bumper of the vehicle essentially. Then I would predict without any offset and apply those offsets to the predicted transforms. A potential problem is that every predicted transform would have to make 3 nav mesh queries instead of one, but that might be okay. I probably need to test that out. Thanks for the tips!

    • @chiefcloudyeye0489
      @chiefcloudyeye0489 5 місяців тому

      @@MadrigalGames unrelatedly you should consider making a discord server or something similar for discussion of the game

    • @MadrigalGames
      @MadrigalGames  5 місяців тому

      Yeah, the plan is to set up a Discord server when the demo release gets closer.