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"

Send a message without casting.

So, I'm creating a widget that I can toss into a slew of different menus (that are widgets themselves) that selects a player 1-4. I'd like to have it call a function/event or what have you that tells its parent a player has been selected and gives the player number.

I know with the custom events, I have to get reference to the object, and cast it to the correct type. The problem I'm having is that widgets can't inherit from other widgets, and I have several different menus that can all be individually showing different players, so I'd have to go to each menu one by one, cast it into one of the menu types, and if it succeeds, tell it the player's been selected. I'd rather avoid doing that since every time I make a new menu, I'd have to add it to the list of possible casting types.

Event Dispatchers are no good because I still have to cast it to the correct type to get reference to the event I want called (or I simply don't understand event dispatchers).

Blueprint Interfaces have the same problem, you have to cast it to the correct type. I just want to basically send a message to an object that says, "Hey, this player was selected, do stuff with it."

I want to be able to simply drop it into a widget, it automatically finds its parent and tells it when a player is selected and which player it is.

I'm wondering if there's a way to send a message like that, or am I wasting my time looking for a way around it?

Product Version: UE 4.10
Tags:
more ▼

asked Apr 08 '16 at 06:10 PM in Blueprint Scripting

avatar image

Yulgalminakf
73 12 18 27

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

1 answer: sort voted first

Blueprint Interfaces exist so that you don't have to cast to a type before sending a message. I think you may be mistaken there.

Once a class implements a specific interface function, you could ALSO cast an object to the class and call the function directly, but you can send an interface message to any object that I'm aware of, and if the object doesn't implement the interface then nothing will get called on it.

You may need to unclick the "Context Sensitive [ ]" checkbox to see the interface call option in your blueprint action menu.

I haven't used it with widgets myself, yet, but it worked well for me with some actors I was dealing with that didn't have a common subclass.

more ▼

answered Apr 08 '16 at 07:04 PM

avatar image

CleanCut
2.1k 67 84 77

avatar image Yulgalminakf Apr 08 '16 at 07:10 PM

Wow, okay. I had tried something like interface before but couldn't get them to work. I had to close and re-open the engine to make it recognize the interface existed... Thanks.

(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