Bake 2D navmeshes with tileset collisions | Godot 4.2

Поділитися
Вставка
  • Опубліковано 4 лис 2024

КОМЕНТАРІ •

  • @aawwilson
    @aawwilson 2 місяці тому +1

    Tutorials don't get better than this. Thank you, sir.

  • @natehandy7121
    @natehandy7121 11 місяців тому +6

    Thanks for putting this together, I understand this much better and got it working. One suggestion, since the NavigationRegion only detects the bottom layer of the Tilemap, you can put your 2nd layer (Overlay in your case) on the bottom and just change the z-index to be over top the 2nd "ground" layer. This might not work in all cases but it eliminated the need for putting the collision items on multiple layers in my project.

    • @octodemy
      @octodemy  10 місяців тому

      Glad you liked it.
      Nice tip there if you got it working.

    • @spang1e858
      @spang1e858 10 місяців тому

      great idea, this is a good work around, thanks :)

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

    +1 for that nav region layer 0 tip, especially that in comments someone mentioned z index, neat

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

      Glad you liked it.
      Godot 4.3 will update how tileset works, so there won't be 'layers' anymore, now each layers is its own node. I think that'll help in these cases so there won't be confusion.

  • @JackieCodes
    @JackieCodes 10 місяців тому +3

    thank you so much! Great video, I had a problem with the terrains not baking and this solved it splendidly, cheers!

    • @octodemy
      @octodemy  10 місяців тому

      I'm glad that it helped :)

  • @stephenvickers8173
    @stephenvickers8173 4 місяці тому +2

    I never usually leave comments but wanted to say, thanks for this! I had spent days trying to work this out and your video showed me where I was going wrong.

    • @octodemy
      @octodemy  4 місяці тому

      Glad it helped.
      Thanks for the comment !

  • @HomeofLawboy
    @HomeofLawboy 4 місяці тому +2

    Absolutely saved my life.
    You can also do this via scripting to generate navigation for procedurally generated tilemaps, which is my case.

    • @burntrice3899
      @burntrice3899 Місяць тому

      Hi, I'm trying to do the exact samething, do you mind sharing how you did this?

  • @ThefarryNem
    @ThefarryNem 11 місяців тому +4

    Thanks for making this video! I've been bugged by a certain issue for 2 days that you helped me solve

    • @octodemy
      @octodemy  11 місяців тому +2

      Glad to hear that :)
      What was the issue that was bugging you, if you don't mind?

    • @ThefarryNem
      @ThefarryNem 11 місяців тому +1

      It was the fact that Godot parses only the 1st layer of a TileMap when baking a NavigationPolygon. Not sure why that's the case

  • @rcdspx
    @rcdspx 10 місяців тому +2

    Thanks for this video! this helped me figure out a few issues i had... in my case i was setting up a Navigation Layer instead of a Physics Layer for the TileMap as you've shown, while that worked for pathfinding with the baked mesh, there are no TileMap collisions this way, and when i added those with the Physics Layer, they seemed to cancel each other, so sticking with just the Physics Layer instead got me better results, i'll need to dig in more into what Navigation Layers in the TileMap are best used for.

    • @octodemy
      @octodemy  10 місяців тому +1

      Glad it helped :)
      Yea, The name 'navigation layer' is honestly confusing. But essentially it is another completely different way to make navigation meshes before baking navmesh for 2D were a thing. It is still kept there mainly for backwards compatibility.
      But I never researched it, so I might be wrong.

  • @shadowman_93
    @shadowman_93 5 місяців тому +2

    I was exactly looking for navmeshholes thanks!

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

      Glad to help.
      It is really weird how the holes only work in the opposite direction.

  • @bdogabriel
    @bdogabriel 5 місяців тому +2

    This just saved me hours of search and debugging. Thanks!!!

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

      Glad to hear that

  • @brunosouza3326
    @brunosouza3326 6 місяців тому +2

    Exactly what i needed! awesome video!

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

      Thanks. Glad you liked it.

  • @zaludaoldrich
    @zaludaoldrich 3 місяці тому +1

    Hi, thanks for the great tutorial. I had no idea that the direction of the drawing is also crucial for the navigation polygon.
    If I could ask, I'd also appreciate some guidance on NavigationLink - I don't know what I'm doing wrong, but it's never worked for me.

    • @octodemy
      @octodemy  3 місяці тому +1

      The one I used on the video is the automatic link feature. As long as two navigation meshes are close enough together, godot will create a navigation link. You might want to increase the project settings minimum distance to create a link. The default one will only create a link is the two navmeshes are practically overlapping.
      There is also no clear indication whether the link is being created or not unless you start the game with navigation debug info and check for those purple lines
      The other alternative is to use a Navigation link node that you can manually set the link between two navigation meshes.
      After the link is made. The navigation agents should be able to seamlessly find points in the linked navigation meshes.
      NavigationLinks are sometimes used to make jump points between areas (in 3D environments). But to make it look good, you'll need to work with some code to sync your agents with the links and animations. Its a bit more envolved. I haven't tried or needed to use this yet so I don't know much about it.

  • @Kepals8766
    @Kepals8766 3 місяці тому +1

    thanks blud! this helped me

  • @saveriov.p.7725
    @saveriov.p.7725 7 місяців тому +2

    Thanks so much for this. No problem about there being no pause between sections. I had to pause the video a bunch of times and rewind a lot anyway to get this working while watching.
    By the way, do you know how to link two navigation regions together which are on separate nav layers? I have enemies transitioning to an "upper" layer when they climb up some stairs and I want them to switch to that separate nav layer, but I also want them to be able to find the player from the ground layer, so I want them to kind of pathfind between layers. I noticed a NavigationLink2D but not sure if that would solve it.

    • @octodemy
      @octodemy  7 місяців тому

      Never used layers all that much, but if an Agent uses Layer 1-2, a NavigationLink that has layer1-2 and is connected to a region with layer1 and a region with layer2.
      He can move in all of them with no problems.

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

    gud gud tutorial

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

      Thanks. Glad you liked it :)

  • @willabyuberton818
    @willabyuberton818 7 місяців тому +2

    When I select the NavigaionRegion2d, I don't get the option to bake or clear the polygon. Only the node editing buttons. I can make a region, but not bake it. Any idea what's going on there?

    • @octodemy
      @octodemy  7 місяців тому +2

      The bake feature only released on Godot version 4.2
      My guess is that you are not using Godot 4.2?

  • @carlos_7x
    @carlos_7x 3 місяці тому

    I'm having issues with understanding the Tile placement tip. I have a second layer in my Tilemap for things that I want objects to collide with, and other objects that won't collide. But I can't get the navigation region to avoid these tiles of layer 2.

    • @octodemy
      @octodemy  2 місяці тому

      So the way it works currently (4.2-) is that only the LAYER 1 is actually used for the baking. All other layers are completely ignored while generating the navmesh.
      The tip was to place object that had the collision on the layer 1, then on layer 2 hide it with the floor tile, and on layer 3 put the object again just to have the visuals correct.

    • @carlos_7x
      @carlos_7x 2 місяці тому +1

      @@octodemy Thanks for the response. That won't work for me because I have 2 physics layers. The workaround I used was to have 2 TileMaps haha.

    • @octodemy
      @octodemy  2 місяці тому +1

      This problem should be solved in godot 4.3.
      Now each layer is a node so you can just set the navigation mesh to bake using all of them.
      I might do an overview video about the new layer node after 4.3 releases. It should release in a few weeks time.

  • @microwire007
    @microwire007 8 місяців тому +1

    With this. If I wanted a CollisionPolygon2D in my world to outline say a river, can I then add that to the Navigation group and it'll treat it as a collision and avoid it?

    • @octodemy
      @octodemy  7 місяців тому

      Yes you can.
      But I think you need it to be a static rigidbody for it to work. Only the CollisionPolygon2D wont work.
      -
      You can also set the mode to "meshes and static colliders" and then I think it'll detect Polygon2D as collision meshes. Worst case, you set the it's visibility off, and it'll be the same result.

  • @kosm460
    @kosm460 6 місяців тому

    But can it be done in code

  • @HalfFang
    @HalfFang 4 місяці тому

    How and can this be used in 2d platformer type games?
    would it still work?

    • @octodemy
      @octodemy  4 місяці тому

      Maybe for flying enemies. But else, you can't. 2D platformers involves gravity and jumps, and that adds extra complexity.
      You can't use the default navmesh for that.
      You'd need to make your own custom navmesh for that, but that is a bit advanced.
      There are a couple of 2d platformer navmeshes addons. But they are a bit old and only for Godot 3.2.
      Maybe you could take reference from them to make your own.

  • @zebini
    @zebini 6 місяців тому

    My pathfinder NPC is getting close to obstacles, so close that it's ignoring the navigation polygon... any ideas why?

    • @octodemy
      @octodemy  6 місяців тому

      Did you try playing around with the values of agent radius and cell size? I think I talked about that in the middle of the video.
      Maybe algo change the target/path desired distance inside the agent.

  • @erkling5865
    @erkling5865 10 місяців тому +1

    is this available for godot 4.2 only?

    • @octodemy
      @octodemy  10 місяців тому

      Yes, 2D navigation map baking is a new feature introduced in Godot 4.2.