#Make navagents avoid tiles with collision on tile on layer 1 when a navigation tile is below it.
10 messages · Page 1 of 1 (latest)
anyone??
Hi there 😊,
I think a bit more context would be helpful, since Physics, Tile maps & Navigation all have layers and masks it's (at least to me) unclear what should interact with what.
Also, I encourage you to describe the game feature in game not only engine terms. So, what needs to be happening to the player to make the desired effect/feature work.
Well currently I have a tilemap with a character on it. I want to then be able to move the character when I click on another position on the tilemap but it needs to also avoid any tiles that have no navigation layers assigned to them. The issue is that if I have a tile on layer 0 with a navigation layer and a tile on layer 1 with no navigation layer but a collision layer, the nav agent still wants to pass through. For now I just set the tile on layer 0 as an alternate tile with no navigation layer and that seems to work.
For some context, I want to have a character that occupies a number of tiles. So in order to do that I'm going to place a tile with no nav layer wherever the character is. Tbh there's a few more problems since I need to ensure that when the character moves it only is able to move where it can fit (i.e. there is enough tiles throughout the path to accommodate all the occupying tiles) which I'm not sure how to do. I also need to convert the pathfinding info from the nav agent into a path along the tilemap (i.e. an array of cell positions the character needs to move across within the tilemap rather than just in global space). Hope this gives better insight into the problem!
Alright, is there a reason the navigation layer and the collision objects need to be separated? Or is it just additional collider objects are on another layer?
You could read the tilemap layer with the colliding tiles and add those to the NavigationPolygon of the navigation layer.
https://docs.godotengine.org/en/stable/classes/class_navigationpolygon.html#class-navigationpolygon
Inherits: Resource< RefCounted< Object A 2D navigation mesh that describes a traversable surface for pathfinding. Description: A navigation mesh can be created either by baking it with the help of ...
Hmm well ig it's not that big of a deal i'd just have to replace the base tile with another tile that has no navigation layer.
Wait how could I add a navigation polygon to the navigation layer of the tilemap?
Aren't those used by nav regions? I'm still pretty new to navigation within godot btw
There are some examples in the docs:
https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationmeshes.html
I'm not experienced enough with multi-layer tile maps to state if the described process from the docs is the only way to do navigationmap updates, but I think it's the way to go.
It's a bit to read up on, but it's well written, with examples, so worth it.
2D and 3D versions of the navigation mesh are available as NavigationPolygon and NavigationMesh respectively. Navigation works independently from other engine parts like rendering or physics. Navig...