Collision Detection
Understand how to implement collision detection in a Rust-based dungeon crawler using ECS architecture. Explore querying player and enemy positions, using command buffers to remove entities after collisions, and integrating this system into the game scheduler to enhance modularity and code reuse.
We'll cover the following...
We'll cover the following...
Removing monsters after collision
Let’s remove the monsters after the player hits them by adding collision detection. We’ll write a combat system in the Health and Melee Combat chapter. For now, walking into a monster will remove it from the dungeon.
Collision detection will be its own system. Adding a new file to the src/systems/collisions.rs, adding mod collisions; to the src/systems/mod.rs file.
-
This system requires access to
Point,Player, andEnemy. ...