-
Notifications
You must be signed in to change notification settings - Fork 9
Picking Up Potions
Potions often provide various benefits to the player or game characters, such as healing, enhancing abilities, or granting temporary buffs.
The ItemPickupComponent is a crucial part of the game's code responsible for handling the pickup of items like potions. This component is associated with entities that represent items on the game map. When a player or character comes into contact with an item, such as a potion, this component triggers the pickup action.
The ItemPickupComponent class has a constructor that takes a parameter called targetLayer. This parameter specifies the collision layer that trigger the pickup when a collision occurs.
In the create() method of the ItemPickupComponent, we set up the event listener to handle collisions between the item and other entities:
The pickUp method is at the core of the pickup process:
The PotionFactory class is responsible for creating potion entities in the game. When creating potions, it associates them with various components, including the ItemPickupComponent, to enable the pickup mechanic.
The process of picking up potions is facilitated by the ItemPickupComponent, which is associated with entities representing potions. When a collision occurs between a companion entity and a potion entity, the ItemPickupComponent triggers the pickup action. This action effectively removes the potion from the game world and allows players or characters to benefit from its effects.
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files