Player Controlled Entities
Player controlled entities, represented by the PlayerEntity class, are entities that are controlled by a player's inputs. Player controlled entities can be either a Model Entitiesor a Block Entities. Yes, that means if you really want, you could even have players control a movable block in your game!
PlayerEntity Class & Entity Controllers
The behavior of the PlayerEntity class based on player inputs is dependent on the logic in it's entity controller (playerEntityInstance.controller
).
In our Entity Controllers section, we covered the lifecycle of an entity controller. Entity controllers have a special lifecycle method called tickWithPlayerInput()
. A PlayerEntity invokes this method of it's controller every tick, passing the current inputs of the player to it.
Through this, the PlayerEntity class, which represents a player controlled entity, is controlled through the logic of it's entity controller based on the input of the player each tick.
To learn more about player inputs and controls, check out Input & Controls
Creating A PlayerEntity
Here's an example from our boilerplate, showcasing how we create a new player entity controlled by a player when they join our game.
You can learn more about the PlayerEntity class options here.
Last updated