Making Monsters Wander Randomly
Learn how to make monsters that can move randomly.
We'll cover the following
Let’s start by making the monsters do something—moving randomly through the dungeon. This isn’t the general behavior we’ll keep for the finished game, but it can still be useful later. For example, if we add confusion, effects may force an entity to move randomly. Bats and other irritants might flap randomly around the map.
Like most ECS systems, the random movement system provides an option for us to use when we add functionality to our game.
We need a way to indicate that an entity moves randomly. This is best accomplished with a simple component; anything that has the component will wander aimlessly around the map. In components.rs
, we create a new tag component:
Get hands-on with 1400+ tech skills courses.