Flashlight for Batteries

Hi people! I want to ask how to create battery, chargable with batteries (+ UMG). I already have a system for battery - when you press F, flashlight will turn on and Print Strings will show it’s energy (from 100 to 0). Now how to create a system for batteries. I mean something like that : Player turns the flashlight on, battery will kill itself. When player picks up battery he’s able to turn it on for some time. Player has capacity (maximum batteries he can carry) maybe 3 or 4. So please, any ideas?

You could create a Battery Actor that the player can pickup. All this Battery Actor would do is modify a variable on the player that controls how many Batteries you have in reserve.

When a Battery is depleted or more literally when your timer for how long a Battery should last runs out, you deduct 1 from the reserve batteries counter.

When you go to turn on the Flash light, you must first check if there is any reserve Batteries that can be used.

If there isnt, then the Flashlight will not work and the Player would have to find Battery Actors to pickup to receive more reserve Batteries.

Could you please send some images of BPs? Might help more…

These are pretty crude as i did it quite late and past my bed time :stuck_out_tongue: But they should be sufficient to help you.

You need to add a Spotlight component to your character to interact with.

And then create an simple BatteryPickup Actor with a SphereCollision component where you use its OnComponentBeginOverlap Event to detect if the player has picked it up.

what are the values of the variables?

ReserveBatteryTimerInSeconds is set to 10.0

It is the only variable that isnt 0. It determines how long a battery lasts.

alright thanks ;D

If this helped you can you please mark this answer as correct to close this ticket.

Thank you.