#path-finding #tilemap #bevy #nav-mesh #gamedev

seldom_map_nav

Bevy plugin that does navmesh generation, pathfinding, and navigation for tilemaps. Navmesh generation is available without Bevy dependency.

5 releases (breaking)

0.5.0 Jul 15, 2023
0.4.0 May 7, 2023
0.3.0 Mar 12, 2023
0.2.0 Nov 13, 2022
0.1.0 Oct 8, 2022

#1274 in Game dev

MIT/Apache

39KB
593 lines

seldom_map_nav

Crates.io MIT/Apache 2.0 Crates.io

seldom_map_nav is a Bevy plugin that does navmesh generation, pathfinding, and navigation for tilemaps. Navmesh generation is available without Bevy dependency. It is agnostic to the solution you use for your tilemaps, but doesn't require much glue. It is also agnostic to your position type, as long as it implements Position2<Position = Vec2> from seldom_interop (ex. Transform). It's compatible with seldom_state with the state feature.

Features

  • Navmesh generation for finite, square tilemaps
  • Awareness of navigator physical size
  • Bevy plugin for pathfinding and navigation
  • Integration with seldom_state

Future Work

This crate is currently is maintenance mode, so I'm not currently adding new features.

  • Tiles that can be pathed over in certain situations, such as doors
  • Tiles that cannot be pathed over, but do not need clearance generated, such as holes

The generated paths are not always optimal, even with the greatest quality settings, but I do not plan to fix this myself. If possible, I may switch dependencies to improve this, though.

seldom_state Compatibility

If the state feature is enabled, it will trigger the DoneTrigger when it is done navigating (if it reaches the destination or cannot find a path).

Usage

Add to your Cargo.toml

# Replace * with your desired version
[dependencies]
seldom_map_nav = "*"

To generate navmeshes without Bevy integration, disable the bevy feature and use Navmeshes::generate or seldom_map_nav::mesh::generate_navmesh. See the no_bevy.rs example.

To generate paths without using the built-in navigation, add the MapNavPlugin to your app, add the Navmeshes component to your tilemap (or some other entity), and add the Pathfind component to your navigating entity. To use the built-in navigation, also add the Nav component to your navigating entity. See the nav.rs example. If you are having trouble getting it to generate a path, enable the log feature, and it might tell you what's wrong.

If you need help, feel free to ping me on the Bevy Discord server (@Seldom)! If any of the docs need improvement, feel free to submit an issue or pr!

Compatibility

Bevy seldom_state seldom_map_nav
0.11 0.7 0.5
0.10 0.6 0.4
0.10 0.5 0.3
0.9 0.3 0.2
0.8 0.2 0.1

License

seldom_map_nav is dual-licensed under MIT and Apache 2.0 at your option.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~22–33MB
~523K SLoC