Movement & Pathfinding
Controlling movement or making entities move by pathfinding is critical to many types of games. The HYTOPIA SDK exposes a number of building block primitives you can use to create your own movement logic and pathfinding systems.
Important Building Blocks & Primitives
Below are the most frequently used building blocks and primitives when creating movement and pathfinding logic for entities.
SimpleCharacterController
The first building block that's best suited for relatively simple pathfinding is the #simpleentitycontroller. This entity controller implements basic movement and facing functions to create realistic movement behaviors with defined speeds.
RigidBody
All entities inherit from the RigidBody class. Rigid bodies have a number of physics properties and controls that are necessary for creating custom movement and pathfinding logic. This means, any property or method that the RigidBody class has, an Entity does as well.
We recommend you look through the RigidBody API Reference here to see a full list of available properties and methods.
ChunkLattice
If you're creating more complex pathfinding, you'll likely want to iterate the nearby terrain state of the world to determine the path an entity should take for it's movement. You can use a world's chunk lattice for this. The chunk lattice is useful for retrieving the chunks near an entity, or seeing if specific coordinates have a block set or not, or what kind of block is set. Learn more about the ChunkLattice.
Basic Waypoint Movement Example
We can create some basic movement behavior by providing a set of waypoints our entity will move through. The SimpleCharacterController used will take the most immediate path to the next target waypoint, colliding and potentially being stopped by any terrain or entities in the way. This is simple, dumb movement in this case.
Here's what our movement for our cow looks like!
Last updated