How would I make a usable flashlight

Hi I’m really new to Unreal Engine and was wondering how would you pick up say a flashlight and then you can toggle it on and off. Something like this ECHOES of P.T. | RE77 - YouTube at 28 seconds he picks up the flashlight it then goes into the player and you can toggle it on and off say with F. If anyone has a video or wouldn’t mind showing me it would be really appreciated :slight_smile:

I assume you already have a player character. First I would add a spot light or whatever light is cone shaped. There is a great tutorial somewhere for making a believable flashlight effect btw which I could dig up if you want. Anyway for the togglebility you could just use the “set visibility” node. You would want to make a new input in project settings under inputs and set it to F. And in your characterBP type in the name of the input you just created and add a reference to your light. Drag out from your light and type in “get visibility” also get a “Not bool” from that. Then add a set visibility from your light and plug in “not”. Should work. I’ll add a picture if my explanation was sucky.

Edit: I reread the question and realized I missed something. For the pick up I would add a new actor blueprint. Call it say PickupBase_BP as you could make children of this for other pickups in the future. Add a collision sphere and set it to not hidden in game so you can see it for debugging. Also add a static mesh and set it to a cube for now. Now you have to make sure both your character capsule and this sphere has “overlap events” on. In pickup base event graph, type in on begin overlap and get a branch see if the overlapped actor == your character. You can select it in the drop-down from the == node. Now you should go to your character bp and add a bool called HasFlaahlight or something. Back at pickup bp, add a “cast to (you character name)” plug in “actor” from on overlap and out from your cast add a “set HasFlashlight”. You would have to go back to your character bp and add a branch with HasFlashlight after your f input and also set your lights visibility to off by default.

1 Like

here is the character blueprint

and here is the pickup

there are a lot of flashlight tutorials actually
https://www.youtube.com/results?search_query=ue4+flashlight

Thanks for the reply :slight_smile: If you manage to find the video it would be even more helpful. I will get to attempting this now <3

also pictures help xd

ty this has helped a lot <3

Quick question you know the “Has Flashlight” on the character BP is that to do with the pickup bp?

yes, as you can see by the second picture you are setting it to true once the player walks over the pickup