Using an actor with a widget component.

Can somebody help me out a bit here i am making an actor with a widget component and when i press it i want it to toggle the visibility of a light i got some help but it didn’t work here are two screenshots.

First place a breakpoint on the red ToggleLights node by clicking it and then pressing F9 on the keyboard. Then run your project and try to click the widget. The game should pause and display this part of your event graph. If it doesn’t, then the ToggleLights event is not being fired or handled in that blueprint.

If it does freeze there at the breakpoint, then the problem might be the contents of the SetVisibility array. Try this and let me know how it goes.

Ok i did what you said but nothing really happened when i pressed the button. The game didn’t pause or anything. Here is an error message i get when i exit the game:

OKay it sounds like the problem is with what’s in your SetVisibility array.
Whatever is in there doesn’t have a Root or Parent component like you’re trying to pull out of those array elements.

Try deleting the ForEach and Root Component nodes, than pull off the array a new ForEach node.

Also tell me what is the Class of the blueprint graph in your first screenshot, and what is the Class of the elements in the SetVisibility array.

Unfortunately it didn’t work but here are two screenshots that might help don’t mind the activate windows :D.

The parent class is actor and the class of the variable is point light. Please help.

I am adding them by clicking on the actor in the viewport and then scrolling down and there is like an option there to add the spotlights.

302534-hereguy.png

This is where i add them.

Here is the interface.

It shows that you have at least empty indexes (o and 1) in your SetVisibility array. If you try to retrieve the Root Component of nothing, you will get an error.

The array can hold objects of type Point Light Actor, but you also need to make sure the array is populated with the Point Light actors you want in there. And first thing in the Loop of the Foreach, do a IsValid check on the object coming out of the ForEach node before doing anything else.

Can you show me where you are adding those PointLight actors into the SetVisibility array?

Yes I think the SetVisibility node is only for components and not actors.
However, the Array is full of Actors, so you should be able to use the Set Hidden in Game node instead of the SetVisibility node. Set Hidden in Game is for Actors. If you hide the light, I believe it will stop shining, just the same as if you were to hide the root component of the light, the whole light would disappear and turn off.

Yeah but as i said in my last post i said that i want it to change from visible to invisible and then to visible and then to invisible etc… I don’t just want it to be hidden i want it to be invisible from the start and when i press the button i want it to become visible and then if i press it again it would change to invisible.

I’m not where I can try this myself, but What if you drag from the ForEach node’s Array Element pin and just try to directly set visibility on the light actor without going through the root component first?

Also I am starting to wonder, maybe you shouldn’t use Set Visibility at all. Maybe you should use Set Hidden in Game instead, on the actor, not any of the components. Try that and let me know how it goes.

1: How do i set it directly without going through the root component?
2: I think you may have misunderstood i want like a button that changes the light every time you press not just a button that makes it hidden and not visible.

Using the Set Hidden In Game node in your blueprint, directly from the Array Element pin on the ForEach node, should do that.

But that won’t make it visible again.

Btw the lights aren’t actors they are normal pointlights.

No need for anymore help i got everything working.

Set Hidden In Game node has a boolean checkbox you can set to true or false in the blueprint. Setting it to true makes the thing hidden, but setting it to false makes the thing visible again.

How did you get everything working?

Like this: