The code is a combination of multiple classes, the HealthPickup class is a scriptable object that models a pickup item in a game. It allows for the game developer to specify the amount of health to heal a player on pickup. It subscribes to the Pickup class and when a player enters its trigger collider, it heal the amount of health specified in the healAmount field of the HealthPickup scriptable object.
The Pickup class is the core class in this system. It handles the movement,
physics, sound and VFX parameters for the pickup as well as reacting to a player entering its trigger collider. It provides a Unity Action onPick which a
HealthPickup object subscribes to. Finally, it handles the feedback when a player successfully picks up the item.
The PlayerHealthBar class uses the Health class on the player to update the health bar on the UI. It finds the instance of the PlayerMovement object in the scene, then uses the Health component of the object to update the health bar Image every frame.