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"

Communicating Between Pawn, HUD and Actor Blueprints

I can get my HUD widget to talk to my actor blueprint... but I cannot get either to talk to my pawn blueprint. I will detail my steps below. All my variables are set to public. I am not using any templates. In game modes, my default pawn is the pawn blueprint I am trying to access. (not sure if that makes any difference at all).

This first part works fine for me... I will just detail all the steps so you know exactly what I am trying. To get my actor blueprint to talk with my HUD_Widget I did this: In my actor blueprint, on EventBeginPlay I drag off -> create Hud_Widget, then I drag of the return value and promote to variable (I can also just create this variable in the widget blueprint and call the reference), I name the variable Hud_Ref2. I then set to viewport and go about my business setting all my variables in both blueprints for initialization. Pic01

Now I go back into my Hud_Widget, I have a button I want to do something. Under 'On Clicked' I go into event graph and create an event dispatcher named Teleport_Selected. I drag off the 'on clicked' and call 'Teleport_Selected' Pic02

If I now go back into my Actor Blueprint I can get it to do whatever I need. If I want something to happen when the button is pressed, I drag off the event tick (if I must) -> 'BindEvent to Teleport_Selected', then create a Custom Event and go about my business. Pic03

And if I ever want a variable from my HUD_Widget, I just put the reference in and 'get' or 'set' whatever variable I want. Pic04

I can display scores, display lives, make progress bars fill, I can make my static mesh (the Actor blueprint) move depending on which button was pushed in the game. I can make the game end and change to a start menu. - Life is great and I feel like I know what I am doing.

Then I try to do the same for my Pawn Blueprint and it won't work. I start with a very simple variable and print string. At first I just tried to create a new reference to the HUD_Widget like I did with my actor. I kept getting the 'access none while trying to read property error.' I realized the only difference in the actor and pawn blueprints is at EventBeginPlay on my pawn I never did anything. So I set it up exactly like I did in pic 1 except I don't 'add to viewport' since it is already there. (If I do add to viewport my HUD stops working, I imagine because an empty instance is on top of it now?). Now this made my errors go away... and this is the only instance I can access any information from the other blueprint. Pic05

I created a variable string named 'test' in the HUD_Widget blueprint. I set the default value to "not set". Now if I start my game it will print that string one time. If I go back into HUD_Widget and change the default value of test string to "set" and restart the game... it will print it with the correct value so I know I am getting close now.

This is where my problem starts... If I try to execute a custom event off a button set exactly like the actor blueprint... it doesn't do anything. If I call my reference and try to 'get' or 'set' any variables... it also doesn't do anything. It doesn't give me any errors like 'access none' unless I leave out the bit from the EventBeginPlay. It doesn't crash or prevent anything further down the chain from executing... it just acts like an empty wire basically. Pic06

At this point I am expecting it to print the variable 'test'... every time I hit the teleport button... I have tried it all ways. I have tried referencing the Pawn and pulling to the HUD and vice versa. I have tried custom events, I tried custom events not tied to other blueprints (although I was pretty certain that did not matter). I tried it with and without the 'get player controller' connected to the Hud_Widget at EventBeginPlay. I tried casting before referencing but it mostly gives me the blue 'unnecessary' semi error.

Where am I going wrong?? What am I not understanding about casting? Any Help would be much appreciated.

Product Version: UE 4.18
more ▼

asked Jan 10 '18 at 06:14 PM in Blueprint Scripting

avatar image

Nacho Royale
3 1 2 5

avatar image ddpawnloans Aug 22 '18 at 09:40 AM

Great post! Thanks for sharing it with us. Enjoyed reading it. Communication Between Pawn, HUD, and Actor was awesome. https://ddpawnloans.com/watches/

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

3 answers: sort voted first

Hey there, first of all why is the actor creating the widget? Second, doing a bind in the tick is a bad idea, you should do that once like on begin play after you have set Hud Reference 2. Finally, if the pawn you are trying to communicate on the widget is the "player" then you dont need event dispatchers, if you execute Get Owning Player Pawn on the widget it will give you a direct reference.

more ▼

answered Jan 10 '18 at 06:58 PM

avatar image

6k 161 129 304

avatar image Nacho Royale Jan 10 '18 at 07:36 PM


imagine I created a basketball game.

The ball is the actor. And everything about the game revolves around the ball so to start that is where most of my code is. The pawn could be considered the player. (imagine there are no teamates.. just the one pawn, maybe later two)

Although I am a bit confused on that (why an actor is creating the widget).... I partly lied.... When i start the game I am in my level... when that game ends... then it loads the start menu.... originally I tried setting the default level to the menu... but when I tried to load my level it wasn't working..... I realize I will have to straighten that out.... but for now I am still stuck on the basics. - probably because that is how I Frankensteined 8 tutorials all using 1st or 3rd person templates and was only way i could get the hud and ball to talk. lol.

I do try to avoid using the Tick like it has a disease. For now I am simply using it to fire off an event since there is not much else in there - just to test things.

That last bit is where I am confused. I mostly won't need event dispatchers for the pawn.... I am just trying to access variables but i can't other than reading default values at start. I just dont understand what the difference is to the HUD between the Pawn and the Actor. I get that one is controllable.

I would like to make a speed meter based on how fast my pawn player is moving or something along those lines...

and on the flip side... if a variable changes in my HUD... I would like it to make the pawn do something... spin, get faster, etc. something along those lines.

avatar image Nacho Royale Jan 10 '18 at 09:43 PM

awe yeah... that did it... ill post some pics soon for others... I'll add your name to the default High Scores you sexy beast!!!

avatar image xlar8or Jan 10 '18 at 09:45 PM

Good to know :) Please mark the question as answered. As a side note you should create the hud widget on the player controller begin play, because that is the common part whether you have 1 or 10 players.

avatar image xlar8or Jan 10 '18 at 10:39 PM

You have a check mark next to my first answer, below the upvote count (currently at 2).

avatar image Nacho Royale Jan 12 '18 at 05:14 AM

I still have a couple questions if you would be kind enough... and I will post a new question if you prefer.

So... As you pointed out, I should make the Pawn create the HUD and not the Actor.

If I take the CreateWidget out of the EventBeginPlay on my actor... I can't get the two to talk anymore. I feel like I could fix the bindings by casting to my actor from the widget, like from the 'on clicked' like you showed me with the Pawn, although I'm not sure what to substitute with the 'get owning player pawn' for the actor...

But before I go through that I noticed if I just keep it in there, set the variable, then remove from parent.... everything works...

So my question is technically, what am I doing?

Like when two blueprints Create a Widget

Is it making 2 widgets right on top of each other and only 'showing' the one I add the "set to viewport' with?

I feel like that is... so then I wonder... How come I cannot just replace the 'CreateWidget' at the EventBeginPlay, with a cast to widget, or a set variable (reference to widget)? and If I can cast to widget... what do I plug in the object type? Tried player controller, owning pawn, reference to widget, If i reference the actor it says 'doesn't inherit from actor'.

casting makes sense to me on an overlap. but that's about it. I feel like on an overlap... you just cast to something.... to see if that is what overlapped... the object type is itself... so it makes sense. If it is that thing... then it will do whatever you connect to the execute pin... and if it's not that thing it will do whatever you connect to the cast failed pin.

But when I make a blueprint cast... object screws me up because I always get the... such and such doesn't inherit from this object... so then I think... ok it wants a reference to the only other object I am referencing here, so I plug that in and get the blue... 'I know I am myself' error.

avatar image xlar8or Jan 12 '18 at 10:53 AM

I suggested that you should create the widget on the begin play of the player controller, not the pawn. I'm saying this because the player controller represents the players intent in the virtual world, when you have multiple pawns that could be possessed overtime, its better to just create the hud on a place that you know is always the same. You can access the pawn using the Get Owning Player Pawn inside of the widget, so you'll get a reference for the currently possessed pawn. Some images would help me understand better what are your doubts.

avatar image Nacho Royale Jan 13 '18 at 05:52 AM

That makes sense. My actor is so close to being the constant in the game but a player controller will always be there. Anything else you think I might overlook go ahead and blurt it out. I do at least always run with stat fps on to avert catastrophes. My 2D Render was SOOOO coool. lol.

just to be clear...

I can control a pawn directly with a keyboard or joystick... but NOT an actor?

I need an outline of how to control pawns... doesn't have to be super in depth.

like A. make a controller (or controllers) b. set the camera here c. give control over using this d. don't forget this. e. everyone gets this part wrong.... f. to change back do this..

In the end I want to make 1 input move 2 pawns at the same time (sharing a camera.) and then a little later, I want to change from that setup... to a 3rd pawn with a different camera for a few seconds... and then change back to the original setup.

If 1 input can't move both pawns is ok if it could at least be the same joystick ie left analog stick controls 1 unit, right stick controls the other.

At the very least I just need to know how to switch between 2 pawns with their own camera's. (not being used at same time.)

avatar image Nacho Royale Jan 13 '18 at 06:25 AM

This video helped a bit... If I cant figure it out I"ll post a new more specific question and then link you to it or something. thanks again! https://www.youtube.com/watch?v=UXFl_yWQjLs

avatar image Nacho Royale Jan 13 '18 at 06:39 AM

I hadnt actually made a play controller up to this point... or wasn't aware of it since it is not referenced as a blueprint in the content browser. In my level blueprint on begin play i just get player controller and plug it into a set view with blend, then create the HUD_Menu (which works but not the first time for some reason). A button on that launches the level on then on begin play of my actor, like you pointed out... I created my other HUD_Widget. When a certain variable is met that actor then loaded the Menu back.

avatar image Nacho Royale Jan 13 '18 at 08:28 PM

sorry for all the unnecessary comments... Ok, I got things set up using the new player controller and I am comfortable switching pawns now. Things are pretty good except I am still confused on some fundamentals.

Originally I had a camera in the level. In Level Blueprint I set the View with Blend using that Camera at EventBeginPlay.

When game starts.. I am viewing from that camera, like I always was. When I switch to Pawn A, it changes to that camera.. which is great. When I switch to the other pawn, it changes to that pawns camera... which is way cooler than I thought it would be. So now I want to keep those cameras and switch back to the original... so that after they have selected their pawn... they can toggle cameras between that original camera... or the new ones. Originally I was just going to set Pawn B's camera back to where the original camera was set.

So it seems obvious I Should just 'set view' or 'set view with blend?' when the player presses a button. to give them that other camera... the problem is I cannot get a reference to the camera in the Player Controller Blueprint. Or know if that is even what I really want to do.

avatar image Nacho Royale Jan 13 '18 at 09:06 PM

by the way, no I don't plan on asking questions forever, lol.

But am super appreciative that you pointed that out about the player controller because that would have been a nightmare to deal with later after setting all the HUD variables.

For the most part I am just testing the basics of everything before I get into it.

I already learned that my setup was way off. So again thanks for everything man, you're awesome!

avatar image Nacho Royale Jan 13 '18 at 09:23 PM

This is what I am talking about...


avatar image Nacho Royale Jan 13 '18 at 09:29 PM

I feel like I should just get rid of that camera, add one to the player controller... then offset its position to where the old one was.

avatar image Nacho Royale Jan 13 '18 at 10:06 PM

Ok I tried that and this is what I get...


avatar image Nacho Royale Jan 13 '18 at 10:27 PM

Ok.. I found this.

Switching Cameras

View target with blend is looking for an actor...

and there is a difference between a camera... and a camera actor which is what my other camera was... I just didn't realize it because I made it using a tutorial weeks ago.

I'm going to stop now because I am way off the original topic and am probably breaking rules or something.

Thanks again mate.

avatar image xlar8or Jan 14 '18 at 01:58 PM

No problem :)

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

Man, thanks so much, I was stuck on that for days. If it makes you feel better... I have not had to use my event tick yet. I always try to find a way to avoid it. And thanks for reminding me to move whatever Custom Events I did have from the EventTicks to the EventBeginPlays.

Where I was going wrong was what I was plugging into the object type whenever I would cast to my Pawn. Initially, I tried to make a reference to the Pawn... just like I made a reference to the widget in the Actor, (only I didn't promote it from something... I just went in the HUD_Widget and created the variable, found the pawn under object types, and named it Pawn_Ref1). That is where I would get errors. If I left it blank it said error, If i put the pawn reference I just made it would tell me I didn't need it... which I understood (I already knew what it was since I had the reference).

I mean, I still don't see what the difference is between the variable reference I created is and the 'get owning player pawn' - since they both point back to the same blueprint or object in a sense.... but I suppose in 6 months I will, lol.

Anyways... This is what I was trying...

Pic07 Pic08

Pic 8 Is what I was talking about... I didn't know what to put in object. If I left it blank, error and if I put the reference I made it said it already knew it was that.

And this is what made it work thanks to Xlar8or

Widget Pic09

Pawn Pic10

Now as Soon as I star the level it prints the string over and over... The variable "Test_Bool" is stored in the Pawn Blueprint. Every time I click the button on the widget it toggles the boolean and my print string changed from false to true or true to false.

I'm not sure I even need the stuff at the event begin play on the Pawn now? Not if I'm using the Widget to act right? I still haven't tried to go the other way... have the pawn set the widgets variables but I am not sure I need to.

Thanks Again so very Much!!!!

Awesome, will do.... how do i mark it answered... looking everywhere

more ▼

answered Jan 10 '18 at 10:34 PM

avatar image

Nacho Royale
3 1 2 5

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

I'm going to go ahead and explain this to beginners such as myself.

In order to communicate between blueprints you will need a reference to the blueprint you are attempting to talk to. Before you can do that, you will often have to cast to the other blueprint first which I will attempt to explain.

You can cast to the other blueprint at the beginning of play and store your reference for later or you can cast to the blueprint only at the time you need to, like when a button is pressed on a Widget, a key is pressed, or on an overlap. I prefer to cast to any blueprints I think the current blueprint I am in will need at EventBeginPlay. This way later I can just pull my references instead of casting each time.

I was having lot's of problems casting, particularly with objects.

There may be more than 2 types, but for what we are talking about there is simple casting like on an overlap event. And then there is casting between blueprints which is what we are after. I will cover both real quick.

Overlaps are good. Any time you can tie something to an overlap event instead of a tick you will be doing yourself a favor since it only happens when the overlap occurs. They are also easy to cast with because the EventOverlap has on object pin on it. Whereas EventTicks and others do not.

So, on an overlap, you simply cast to an on object to see if that is what overlapped. For the object type you connect the other actor pin. My example is an actor blueprint. Whenever it overlaps anything, it checks to see if it is one of the boundaries. First it checks the side, then the top etc. If it did overlap with one of those objects, then destroy actor destroys the actor, not the boundary.

Overlap Cast

Casting to a blueprint is a little bit different.

Blueprint Cast

Mostly you just need to put a 'get all something of class' and plug it into the object type.

If it's an actor it would be actors of class. in the previous pic I am casting to another Blueprint called Player_Controller whose native parent class is 'Player Controller'. However it is still found under "all actors of Class"

If It's a Widget, like your HUD, then it will be found under "All Widgets of Class", Like this:

Widget Cast

Other Pawn and Actor Blueprints will also be found under "Get all Actors of Class" and can be handled the same way.

To further explain the above pictures... On EventBeginPlay, we drag off, get all actors of class (our target blueprint). Once we get that, we drag off the array pin called "out Actors' or 'Found widgets'. Then we type -> get(copy). We drag off of that and type "Cast to..." and whatever we just came from pops up. *(note below) Connect the white execute pins. Now, on our newly placed 'cast' node, drag off the 'as player controller' or 'as player HUD widget'. Type "promote to variable. This will place the set variable you see called 'Set PC Ref Ball' or 'Set HUD Ref Ball'.

Name it what you want. This is now your reference to that other blueprint. If you want to pull another variable, first you will place this reference. You can do that by dragging it in from the left panel that lists your variables. You want 'Get'. You only 'Set' it at the beginning. (Setting it without properly casting first will also give you errors. The editor might not warn you so it looks ok, but then it won't work in game.) (**Final Note) Then you will drag off that and type 'get....' this will then give you access to whatever the other blueprint has. Or you could type 'Set...' and then change the variable that is stored in the other blueprint. like this:

Getting Variables from other Blueprints

  • (note) We don't have to worry about the index of the Array because often there is only 1 instance. I have only 1 player controller named xxx. I have only 1 Widget named xxx. I could have other widgets... but they will have different names. Now If I had an actor that represented say an NPC, and there were 30 instances of the same blueprint in my level... then I would need to worry about the index. It needs to know which one exactly are we talking about. I don't know as much about that yet so I will not elaborate on how to go about that. But if you are trying to figure out how many there are of something you could do this:

Array Loop

  • (Final note)

This won't work

But this Will

If anyone could explain that Blue Error I would love it. If you get all actors of class first it will work fine. At least it does for me. If I unplug object type, plug in anything else, or don't get all actors of class... I cannot get anything to work.

and since it was mentioned briefly, here is how you take over another pawn. Pawn Possession

That is being done from my Player Controller Blueprint.

The equivalent to 'EventBeginPlay' in a widget is 'EventConstruct'

more ▼

answered Jan 15 '18 at 08:01 AM

avatar image

Nacho Royale
3 1 2 5

avatar image Nacho Royale Jan 15 '18 at 02:07 PM

in "getting variables from other blueprints' the little eyes next to the variable represent whether the variable is pubic or not. The ones shown are public which means other blueprints can see them (if referenced properly). If they eyes look closed, that means they are private (i think, not public?) but it means that other blueprints will not be able to see them (even if properly referenced).

avatar image GarnerP57 Jan 15 '18 at 03:40 PM

This is not the case. Private blueprint variables can be seen when using a direct reference. Not sure if this is the intended behavior but it is how it works now.

The eye aka "instance editable" enables you to hide the variable from being set in the details panel of an instance placed in the world and has to be enabled if you want to expose a variable on spawn.

If you tick the "private" box under variables you won't see the variable in derived blueprints though, but you can still get it from other blueprints.

avatar image Nacho Royale Jan 15 '18 at 07:28 PM

Thank you for clearing that up. Do you have any clue on that Blue semi error i get when casting?

Also, If you are trying to pass variables between levels then I found this guide https://answers.unrealengine.com/questions/548875/pass-variable-between-main-menu-and-levels.html

avatar image Nacho Royale Jan 16 '18 at 03:10 AM

I think I figured out the blue error in the "this won't work" and "but this will" above...

When you 'get all actors of class' you don't need to cast because you already know what you have. I think all you have to do then is drag off the 'get' node and promote to variable... instead of cast to, then promote to variable.

Like this: No Cast Needed

(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