Pathfinding and Async Tasks in Bevy

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 มิ.ย. 2024
  • This is just a quick video showing how to use the pathfinding crate and async tasks to create a pathfinding solution for a bevy game. The source code is up but it's an early draft for my future tutorial series code.
    Discord Invite: / discord
    Patreon: / logicprojects
    Source: github.com/mwbryant/logic_man...
    0:00 Intro
    0:47 Grid System Overview
    1:31 Pathfinding Crate
    3:55 Bevy Tie In
    4:44 Async Compute Tasks
    7:06 Outro
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 29

  • @vincenthoward9378
    @vincenthoward9378 ปีที่แล้ว +8

    Cannot wait for the new Bevy release along with your new series

    • @logicprojects
      @logicprojects  ปีที่แล้ว +2

      I'm excited too! I've been drafting it for a while

  • @stephenjjbrown
    @stephenjjbrown 10 หลายเดือนก่อน +1

    I've been implementing pathfinding in my Bevy game and have referenced this video so many times. Thank you for putting this together!

  • @TheTwyker
    @TheTwyker ปีที่แล้ว

    I cannot tell you how excited I am about this video ❤☺️🙌🏻

  • @Tszyu01
    @Tszyu01 11 หลายเดือนก่อน

    Great videos. Can you suggest any ideas or resources on enemy entity field of vision. Such as a metal gear solid where enemies have a cone of vision to determine if your character is visible to them.

  • @bigenough2122
    @bigenough2122 ปีที่แล้ว

    cool, thanks ❤

  • @igz
    @igz ปีที่แล้ว +1

    Very cool! How many dudes can you have before you notice any lag?

    • @logicprojects
      @logicprojects  ปีที่แล้ว +2

      It's hard to say, with the compute tasks you don't get frame drops but you can notice the dudes waiting for their pathfinding job to complete for a little bit with larger grids (>200x200). Frame lag would be driven by other systems like sprite rendering

  • @kablouserful
    @kablouserful ปีที่แล้ว +4

    Are you copying the entire grid for every entity pathfind query in every frame? That seems expensive.
    I would instead do 1 grid copy at the end of `fn wander()`. And spawn many tasks all sharing an immutable grid.

    • @logicprojects
      @logicprojects  ปีที่แล้ว

      Yeah I am. That's one of the optimizations worth looking more into. You would need to put it behind a shared pointer. In practice the limiting factor is the raw cost of astar and not the clone in my quick profiling though so I haven't dug into that yet.

    • @kablouserful
      @kablouserful ปีที่แล้ว +4

      @@logicprojects Yes I agree. The overall cost is still dominated by astar.
      But the astar time cost can be hidden by the async nature.
      But the copying is not async to the game loop. So this causes the most amount of game loop lag.

    • @logicprojects
      @logicprojects  ปีที่แล้ว +2

      I realized this last night. You are 100% right that the copy happens in the loop

  • @IcyTorment
    @IcyTorment 4 หลายเดือนก่อน

    Good video, but that dark-grey-on-black syntax highlighting is a bit of a problem.

  • @darknetworld
    @darknetworld ปีที่แล้ว

    May take a while until I start working on the pathing. But good ref still I wonder about the 3D which is tricky since I no clue how it works. I bet it a lot of work and depend how it build.

    • @logicprojects
      @logicprojects  ปีที่แล้ว

      I'm sure there's a lot of resources out there. This crate is just the raw algorithms. I think Unity's navmesh is the general solution where each triangle in a mesh would be one of the graph points you feed into astar (if I understand it right)

  • @cherloire7978
    @cherloire7978 ปีที่แล้ว

    Hey, with the Grid struct, what happens if an Entity is despawned from the game? Do you have to go and manually find that entity in the grid and remove it?

    • @logicprojects
      @logicprojects  ปีที่แล้ว +1

      I have systems in the grid plugin that should keep the grid accurate. Specifically in the grid.rs file in the source (in description) I have a remove_from_grid system that uses RemovedComponents to check for despawns and clean the grid. My main open problem is if 2 entities have the same location the only the most recent will be properly in the grid but I mitigate that with an error log message

    • @cherloire7978
      @cherloire7978 ปีที่แล้ว

      @@logicprojects Ok, thanks. Are there any more general issues with storing entities in places, such as in resources, components, etc as struct fields?

  • @jeffg4686
    @jeffg4686 ปีที่แล้ว +1

    I'm moving into AR.
    I found a great middle ground, for now.
    Unity with C#, but calling into Rust libraries that I build. This would allow best of both worlds for now.
    Haven't done anything yet - still have lots of AR training ahead of me. I want to get past the basics.
    I hated the thought of losing Rust though - put so much time in.
    Gonna move back to Bevy once it gets OpenXR integration.
    this pathfinding is a perfect example. Run that on a whole bunch of items.

    • @logicprojects
      @logicprojects  ปีที่แล้ว

      I haven't looked into much AR myself but I have started toying with bevy on Android. I'm excited to give it some more time when they have a prototype OpenXR ready

    • @jeffg4686
      @jeffg4686 ปีที่แล้ว

      @@logicprojects - there's a lot of great training out there for Unity even if you don't plan on using it - shows you what you can do. Then when OpenXR comes to Bevy, all the concepts are solid. Can't wait for it to come to bevy, but I don't mind using unity for now.

    • @jeffg4686
      @jeffg4686 ปีที่แล้ว

      @@logicprojects - It also looks like the "Component Model" is coming along, so should be able to use Rust compiled to Wasm inside a WebXR app in Unity. Don't know how far out that is. Not sure if Unity compiles to Web GPU (vs webgl) yet either, but likely soon if it doesn't support it already.

  • @indierusty
    @indierusty ปีที่แล้ว

    Without an Editor , Is developing game in bevy is slow in comparison to other game engines? Will bevy have an editor and when?

    • @logicprojects
      @logicprojects  ปีที่แล้ว +5

      It's not slower for the games I like to make that are more procedurally generated. If anything it's faster for me because the editor doesn't really get you much if you're not laying out scenes. Bevy is also missing some of the other built in editor tools like animation state machines and particles. There are plans for a bevy editor this year though!

    • @larperdixon723
      @larperdixon723 8 หลายเดือนก่อน

      Just wanna chime in here.. if you are building a 3d game with scenes where the position and orientations of the objects in the scene need to be taylored, I do not recommend doing that in bevy+rust, I recommend using something like blender to export a gltf (glb) and load that with bevy. @@logicprojects

  • @SuperSkydrake
    @SuperSkydrake 9 หลายเดือนก่อน

    Very good video, I tried your project on Ubuntu linux, it became very slow after 1 minute playing :( I think it have a bug somewhere.

  • @etopowertwon
    @etopowertwon 11 หลายเดือนก่อน

    *Screams silently in imagining copying entire grid of Dwarf Fortress*

    • @logicprojects
      @logicprojects  11 หลายเดือนก่อน

      Probably actually wouldn't be that bad. This grid is just entity references and I tested on maps larger than df. Multiple z levels would start to push it though, definitely a smarter connected components approach would be needed at some point

  • @micycle8778
    @micycle8778 6 หลายเดือนก่อน

    why do they call them von neumann neighbors when they could be called rook neighbors