x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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: umgbppicture

The Actor BP Graph: actorbppicture

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. :)

Product Version: UE 4.10
Tags:
more ▼

asked Feb 06 '16 at 03:40 AM in Blueprint Scripting

avatar image

FusSionzZ97
103 4 6 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Feb 06 '16 at 04:10 AM

avatar image

Stormrage256
1k 83 75 118

avatar image FusSionzZ97 Feb 06 '16 at 05:03 AM

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?

avatar image Stormrage256 Feb 06 '16 at 05:13 AM

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.

avatar image FusSionzZ97 Feb 06 '16 at 08:28 AM

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.

avatar image Stormrage256 Feb 07 '16 at 05:07 AM

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.

avatar image FusSionzZ97 Feb 10 '16 at 05:00 AM

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: alt text

UMG BP: alt text

Platform BP: alt text

Thanks.

avatar image Stormrage256 Feb 10 '16 at 01:41 PM

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.

avatar image FusSionzZ97 Feb 13 '16 at 12:58 PM

Thanks a bunch for your help!

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

UMG BP: alt text

Platform BP alt text

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question