[Game of Purpose] Day 46 – Simple Battery System

[Game of Purpose] Day 46 – Simple Battery System

Today I implemented a simple battery system. It has a status indicator in the top right corner. It has a configurable rate of depletion and automatically turns the engine off when it runs out of power.

First I create a BPC_Drone_Battery component. It has an event DrainTick called every TickEvery amount of time and calls a Drain Charge function.

Drain Charge function simply takes Drain Per Tick away from a total charge and calls Update Charge. It does nothing when the battery is off.

Update Charge updates the Charge variable and calls events: Battery Charge Changed or when it drops to zero Battery Charge Depleted.