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"

How to get a widget blueprint communicate to pawn

I have a NPC character who's parent class is a pawn. Attached to this character is a 3D Widget component that has a widget blueprint with two buttons. When I click on one of the buttons I want to reference the NPC character and fire off an event.

What I'm struggling to figure out is how do I reference the NPC from the blueprint graph in the UI? Attached is an image of what I'm trying to sort out. Should I make a reference to the NPC in the level blueprint? It's possible I'm going about this completely backwards, so if there's a better way to handle this I'd love some help.

alt text

Product Version: UE 4.14
Tags:
communicate.jpg (82.4 kB)
more ▼

asked Feb 28 '17 at 05:17 PM in Blueprint Scripting

avatar image

rustbucket1971
16 5 7

avatar image plastik21 Sep 22 '17 at 07:19 PM

Don't let UI blueprints access pawn blueprint. Use event dispatchers. I need to go, sorry :D

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

1 answer: sort voted first

So I managed to solve my own question (that happens when you finally ask for help...) When a button is clicked I do a "get all actors of a class" and look for my NPC's class. I know he's the only one so I can just grab the first item in a 1 item array then assign it to a variable of type reference to pawn.

Not sure if there's a better way to do this but it works. I think I will optimize somewhat by setting that pawn reference when the Widget is created.

Blueprint of what I did attached in case that helps anyone.

alt text

capture.png (114.9 kB)
more ▼

answered Feb 28 '17 at 11:18 PM

avatar image

rustbucket1971
16 5 7

(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