How to get a reference to actor component in Thirdperson map level blueprint without placing actor in the blueprint?

Hello everyone,

I am using the ThirdPerson Map and I created an actor blueprint class named “button” where I added a cube, collision box and pointLight components.

Here is my goal: I want to switch on/off the light when the character presses E on the area marked by the triggerbox. however, I don’t want to place the button actor on the blueprint itself because it’s attached to an item that should be placed at runtime.

my question is how do I get a reference from the pointLight component from the button actor class to use it in the level blueprint without placing the button actor in the third person map so the action will be applied to any instance of that button created at run time instead of only a single button?

Thank you.

Hey. Your problem is solvable with the help of “Blueprint Communication”.

I have to say, you did a great job describing your problem. But there is more to consider.
For example, how “scaleable” or “reusable” you want this to be.

I think you should take a look at the following video: Blueprint Communications | Live Training | Unreal Engine - YouTube
This is Zak Parrish talking about Blueprint Communication. You definitely need to understand the concept and this video is a great way of learning it. I think this is of more use, than a basic “how-to”.

Hope it’ll work fast.

Hi… thank you for the link. I watched up to 1 hr of that tutorial and I feel it’s related but for some reason, I still don’t know how to apply it to my case. I would appreciate your help. All what I need is to test the concept so far. This isn’t actually what I am planning to do with my game but the concept is needed and point light seems to be the easiest thing to start with.

i dont understand you question
i think you mean that you want a refrence so use get all actors of class and array get and everytime add 1

Hey Hoda-

Your goal is to allow the light to be turned on/off while inside the collision box, correct? Rather than doing this in the level blueprint, you can add the functionality directly to the actor blueprint. In the event graph you can setup an OnComponentBeginOverlap event for your trigger box to enable input and an OnComponentEndOverlap to disable input when the player leaves the trigger box. Then you can setup an input even for the E key to toggle the visibility of the light.

If you were to setup the light controls in the level blueprint, then you would only be able to turn the light on/off in that one level. If you spawned the same blueprint in a different level then you wouldn’t actually be able to control the light. Adding the functionality directly to the button blueprint will allow the blueprint to easily be used elsewhere as ND_Dwight mentioned.

Cheers

Thanks all… I appreciate your help.

Thanks .

Your solution worked perfectly with me.