I have a basic flashlight system with battery. I want to have a charging station somewhere in my world where the player goes and presses E to leave the battery and then go do something else to let it recharge for some time. When the charging is over, I want the player to press E again at the station to get the battery back and be able to use the flashlight again. Any ideas?
I’m sorry i can’t really help you in BP cause i try to use only c++ but,
Your system seems like a seek and destroy, you take the bomb put it and she explode, but in your case the battery don’t explode. ( i think you can found more tutorial on that one)
if the flashlight is an actor and the battery too you can make like:
class player => a boolean haveBatteryInInventory.
class receptor → bool isCharging + a box collider => check only for pawn or only your character in beginOverlap.
class battery → bool → isFull, isCharging, isOnPlayer + float maxbattery / currentbattery;
if he’s in the box + haveBatteryInInventory = true
if → isOnPlayer → you can detach your battery and attach to the receptor
(swap boolean to false and true)
(for visual only) Detach the battery actor from player or flashlight and attachto the receptor.
if isCharging => fx for example.
if he’s in the box + haveBatteryInInventory == false+ battery->isFull == true
(for visual only)Can Detach from receptor and Attach to the Player or flashlight.
haveBatteryInInventory = true.
with a timerHandle create a countdown → scd to recharge.
(while) → countdown not finish → if currentBattery < maxBattery, currentBattery += reloadAmount.
if currentBattery == maxBattery isFull = true
if you don’t like box trigger you can use Raycast.
I’m only beginner so it’s not perfect, more than you can have many solution for this system ^^.
for the input create the same and use boolean to know if can take the battery or not.
Have a nice day.