How to create a flashlight that you can pick up and turn on/off?

Hello everyone, I am asking this question because I cannot find a solution to my problem at least I find a solution but it is only 50% suitable.
I’m looking to create a flashlight that can be picked up by the player and then can be turned on by pressing a key on their keyboard / controller.
Currently I only have the means to turn it on and off but the static mesh must remain on the player’s camera, to illustrate this I am attaching screenshots


One very simple way that this could be done is to create two variables. One bool bHasFlashlight is set to true when the character is holding the flashlight. Another bool bIsFlashlightOn is set to true when the flashlight is on. Toggle the visibility of the flashlight static mesh when bHasFlashlight is changed. Toggle the light from the flashlight when bIsFlashlightOn is set to true.

Now this is super over-simplified and a better design would be to have some type of inventory system that uses sockets on the skeleton to mount different meshes on it when being held or worn. Each item would possibly be it’s own blueprint that could be activated through a keybind or some other mechanism.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.