Blueprint Communication Question (Headlamp)

Hello All,

I’m designing a headlamp blueprint that will be attached to the player character and act as a flashlight. Originally, I made this simply by dragging some directional light objects and binding them to an input. Now I’ve migrated the entire “headlamp” to a new blueprint complete with some simple shapes to act as the physical light. The idea is that in the future the headlamp will be an object the player can pick up and use as an item on their character, but for now it simply exists as a child actor component on the ThirdPersonCharacter blueprint.

The problem is that now my code doesn’t turn the light on and off. If I put the Input node in the “headlamp” blueprint, nothing happens (presumably because I’m controlling “ThirdPersonCharacter” and not “headlamp”). I know I need to communicate between the blueprints somehow, but I’m not sure about the best way to do this. Using the “direct communication” method seems really messy to me, as for the time being any given “ThirdPersonCharacter” will have their own “headlamp” attached as a Child Actor Component, and creating a publicly exposed variable seems like a good way to create problems if you scale things up to several characters running around.

What am I doing wrong here? How can I have the inputs from the “ThirdPersonCharacter” propogate to the items it is holding (and only those items - this isn’t a door or a generator or something in the level itself).


Somehow you need to get a referencre to your headlamp, so you can talk to it and use its functions etc. In your case, the best way to do it would be getting a reference when your character picks up the headlamp. For example, if your headlamp is a pickup that the player walk up to and pick up, you can acquire a reference to it with an OnOverlap Event on you character. You can then use that reference to invoke functions on that specific headlamp that you picked up. It would be a good idea to create a function in your headlamp blueprint that provides the functionality that you want and then you can simply call this function anytime you need (for example a key is pressed) from your character.

I hope this helps you a bit.

Ok I think that is helpful. Specifically the part about the functions. I was looking at the wiki section on communication and was wondering about moving the logic of the headlamp over to a function that could simply be called from the character blueprint with a target of the headlamp. I need to do some more reading to see how to implement this, but as it stands it strikes me as a little awkward. It seems like I should just be able to expose a Boolean on the “headlamp” and then modify that variable from the parent “ThirdPersonCharacter”. Either that or the input function call on the headlamp itself should work from the “ThirdPersonCharacter” as long as the component is a child of “ThirdPersonCharacter”.

As for the OnOverlap Event, I’m not quite ready to implement the item as a pickup, because then I would need to implement some infrastructure to actually pick items up before I could work on my more immediate problem. Overall though, blueprint communication strikes me as a little strange. In my case I’m making a headlamp, but it could just as easily be a magazine for a weapon or an artillery shell, or a battery, or anything similar where you could have an arbitrary number of instances that you can’t necessarily control for in advance. Maybe it’s down to my own limited understanding of Object Oriented programming.

Either way, thanks for the reply, I’ll keep posting here once I get it figured out.

Have you seen this video? It is pretty long but explains blueprint communications really well, it might help you if you are confused.