UMG to Actor BP communication and vice versa

I have a button on a UMG BP that when pressed activates a custom event to which executes in another Actor BP.

The UMG BP Graph:

The Actor BP Graph:

The problem i’m having is what am i supposed to be plugging into the object for the cast? I both referenced the button itself and the UMG BP but still fails. As well in other instances where i need to cast from Actor BP to Actor BP, i fail to cast to anything but the Character BP. Any help with me understanding better would be appreciated!

Thanks. :slight_smile:

Thanks for your reply.

How do i set the actors reference in the player controller?

The call for the UMG to get created is in the Character BP. How do i access the player controller?

Well, you won’t be able to directly access the actor from the UMG. But one option to get a reference would be to store the actor reference in a variable inside the player controller that owns this widget. Now on pressed button down event in your UMG, you could get your owning player controller, cast it to it’s type & then retrieve the variable that you used for storing the actor. Using that reference, you could call your ‘Down Button’ event.

If you have created your player controller, you could just use the ‘get player controller’ node and cast it to the player controller blueprint that you created. If not, just create a new one and set it as the default player controller in your ‘Game Mode’.

Now within the player controller, create a variable of type ‘Actor’. You could then use the ‘Get all actors of class’ of Passable Platform class type in order to retrieve all passable platform actors in the level as an array. I’m assuming that you only have one of these in the level. So just get the first element in this array and store it in the actor variable that you created earlier in the player controller.

Even though you’re creating the UMG in your character BP, it will be linked to your player controller. So from within the widget, you can use 'get owning player controller, then cast it to the particular controller type, retrieve the actor, cast it to passable platform type and then call the Down Button event.

I didn’t know player controllers were blueprints!..

So i created one, followed your steps and the casts are working correctly. However i do have multiple platforms scattered around the level so i am having trouble for this to effect every platform on the level.

So basically when the player is on top of these platforms when they press the down button they fall through it, now that were only getting the first/1 element only 1 of however many are being effected. How would i fix this?

Thanks again for your quick replies.

Yes, the player controller is an important blueprint. It can exist even when the player character itself is destroyed. I use them mainly for widget creation & updates.

Alright, so since you have multiple platforms, you’d have to identify the platform with which the player is interacting. For this within the platform blueprint, add a box collision. Now you can use it’s Begin Overlap Event to check when an object overlaps with it. In order to check if it’s a player character, grab the actor parameter of this event and cast it to your player character. If casts succeeds, then you’ve got the required platform. So you can now store a reference to self from this platform blueprint, within the player controller blueprint.

Sorry for the late reply,

What do you mean by “store a reference to self from this platform blueprint, within the player controller blueprint.”?

So this is all what i have currently.

Controller BP:

http://i.imgur.com/3ndkzvL.png

UMG BP:

http://i.imgur.com/s2SZUyO.png

Platform BP:

http://i.imgur.com/vFzOK23.png

Thanks.

Since you’re using a box collision, you do not need to use the get all actors of class and for loop in the controller BP.

Instead in your platform BP, if your cast to side scroller character succeeds, you get the player controller, then cast to it and store a reference to itself with the ‘Passable Platform Ref’ variable in the controller. In order for an actor to get a reference to itself, you can right click anywhere on the blueprint and type ‘self’. This will provide you with the reference to the platform that you store in controller.

Apart from that ,your UMG BP looks fine. So I guess that should be enough to get it working.

Thanks a bunch for your help!

Everything seems to be working well now.
So here’s everything I’ve done

UMG BP:

http://i.imgur.com/YOxg0qV.png

Platform BP

http://i.imgur.com/6P0NaYu.png

Plus the Actor Platform Ref Variable stored in the player controller.