x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can I make a flashlight battery re-charger?

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?

Product Version: UE 4.21
Tags:
more ▼

asked Mar 21 '19 at 06:39 PM in Using UE4

avatar image

NtinosFerret
17 2 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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;

Receptor => 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.

Battery => 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.

more ▼

answered May 17 '19 at 06:55 PM

avatar image

Blbl-Green
1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question