landmass
A Rust crate to provide a navigation system for video game characters to walk around levels.
What is a navigation system?
A navigation system is essentially the collection of tools needed for robust agent movement in video games. This generally involves 4 things:
- Path finding (e.g. A-star)
- Path simplification (e.g. SSFA)
- Steering (e.g. boids)
- Local collision avoidance
In addition, managing agents and the navigation meshes they walk on can be cumbersome, so a navigation system ideally will handle that for you.
Generally it is difficult to find a full, free system to handle all of these for
you, and the goal is for landmass to work relatively easily with other
languages so it can be used anywhere.
Overview
landmass has four major components: Archipelagos, Islands, Agents, and
Characters. An Archipelago is composed of several Islands, as well as the
Agents and Characters that travel across those Islands. Each Island
holds a single navigation mesh.
Each game character (controlled by AI) should correspond to one Agent. Player
characters or other characters not controlled by AI should correspond to one
Character. To start using landmass:
- Create an
Archipelago. - Create an
Island. - Add
Agents andCharacters to theArchipelago.
Each frame of the game:
- Set the position and velocity of each game character to its corresponding
AgentorCharacter. - Call
updateon theArchipelago. - Use the desired move from each
Agentto inform the corresponding game character where it should move.
Note: landmass intentionally does not update the Agents position itself.
Generally, characters are moved using some other method (like a physics
simulation) rather than just moving the character, so moving the Agent would
be confusing.
Example
use Vec3;
use *;
use ;
let mut archipelago =
new;
let nav_mesh = NavigationMesh ;
let valid_nav_mesh = new;
let island_id = archipelago
.add_island;
let agent_1 = archipelago.add_agent;
let agent_2 = archipelago.add_agent;
for i in 0..200
assert!;
assert!;
License
License under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
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.