[BUG?] Set an actor variable on Widget BP

Hi guys!

I think I have found a bug on widgets. I have read many post with the same problem and it’s not solved. So, let me explain what I want to do:
I was reading and testing this post, it’s about blueprint communications:
https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/BlueprintComms/index.html
I did all step by step, and it worked, but when I tried to do the same with a blueprint actor-widget, not. I want to press a button on widget and turn off the light of blueprint actor, it seems easy, and I used to do this with “Get all class of actors” but I have read that I must avoid it. So using function to communicate would be a good solution I think.
And where is the problem? Here: When I try to set the actor blueprint. it doesn’t work:

29-12-2015 19.12.21 3.jpg

29-12-2015 19.12.1 4.jpg

Here other post with the same problem:

What is the solution?
Thank.

The problem is likely that you can’t select a level-based actor from the default values of class-based details panel. You’re creating a class which is not tied to your level, so selecting an asset in the level just won’t work. What would happen if it were used on another level? How would it link to the actor in the level you’re using now?

What you can do is this:

  • Create a function in your widget BP, “GetTargetBox” - it returns a box.
  • In the function, if your box is not valid, do ‘get all actors of class’ to set the target box variable
  • Return the value of the target box

Alternatively, you can set a tag on the box in your level and use get actors with tag, etc. You could even add a variable to your widget which sets the tag you want to search for, so you can use the same class for multiple boxes/tags.

To note: Get all actors of class is not a bad function. It is just slow(ish.) Using it sparingly is fine. Don’t use it every tick, etc. Using it once to find an actor is not a problem, as long as you store the result so you don’t need to do it again.

I’m trying the first option, but I am doing something wrong.

You need to connect your ‘target box’ variable to the is valid node.

You need to set the output of the ‘get’ note to a ‘set target box’ node.

You need to connect return a get target box node

Thanks :wink: Now it works.