I don't understand

Hi Zedrophobe,

Have a look for “Blueprint Communication” on YouTube ( and the forums. At a high level, there are two different ways for Blueprints to interact with each other:

Direct references (call a function or read/modify a variable on another Blueprint)
Via an interface (fire-and-forget attempt to do something on another instance)

Interfaces promote a looser coupling, so you can have a RespondsToFire interface for example, and any fire/explosion can do collision checks and send a TryToIgnite message to things it collides with, without having to know about specific kinds of flammable things.

Alternatively, you might have central game state (‘global’ variables) in an AGameState subclass. Your player controller, etc… blueprints might directly interact with this and call methods on that Blueprint instance (e.g., by calling GetGameState and casting the result to your specific BP type).

RE: The ‘out of scope’ warning on variables inside of a function: You can only view those values when you are stopped at a breakpoint in that function, since the function could get called many times in a frame, and the debugger has no way of knowing which invocation you wanted to debug.

Michael Noland

Ah, partway (Probably 1/5th) through writing a tutorial, and it turns out there are better resources out there already. Oh well, saves me time! :stuck_out_tongue:

This tutorial in specific should be exactly what you’re looking for:

You’ll probably want to use Interfaces most of the time, as are covered in the second half of the video, but I’d suggest you watch both and follow along with both to get the hang of doing this.

Good luck, let us know if those tutorials don’t cut it.

EDIT: Note that you can add inputs and outputs like you would any other function, so you can pass any type of variable you want around your objects.

I was able to get this to work in some fashion but it is still much more difficult than it really needs to be. I shall use Neverwinter Script (Neverwinter Nights 1 & 2) as an example.
**I made the exact function in Unity via C# and works like a charm. Can access data directly from Playmaker (FSM similar to BPs) as well.

void SetLocalInt(object oObject, string sVarName, int nValue);
Stores nValue as a local number within oObject using the variable name sVarName. The parameter sVarName is a unique string identifying a single local variable. Using the same value for sVarName in subsequent calls will overwrite the original value.

This functions the same with SetLocalString, …Float, …Location, and …Object (an Objects UID reference to find that object…if it exists…easily)

Now simply GetLocal… to retrieve what the value is.

As stated to do this in Blueprints is crazy difficult to fluently Set and Get data from objects.

Also on Topic…something else super handy.

object GetNearestObjectByTag(string sTag, object oTarget = OBJECT_SELF, int nNth = 1);
Returns the Nth object nearest to oTarget that has sTag as its tag value. Return value on error: OBJECT_INVALID

In the video pointed above…ShrubToMove would be the Tag of what another Object running a cyclic heartbeat or perhaps when something walks over/into a trigger/collider…that collider runs its script and Gets the nearest Object (could be the 5th Nearest) with the Tag ShrubToMove. Or perhaps run this in a For Loop and get All the ShrubToMove Object within a certain Radius from the trigger/collider. The Trigger would carry the script and the ShrubToMove has zero to configure…no editing of the Graph at all. The ShrubToMove could have a heartbeat script running on it checking a variable that is Set on it from the trigger/collider…but if you have 500 ShrubToMove Objects then that is 500 wasted CPU resources on a heartbeat. Better off Getting the Object and doing something with it at that time…perhaps a Psuedo HB script that will turn itself off after being used would work.

But Krixa, the video show you how to find All Actors of Class. Yes, I saw that. However, what happens when the Questing Systems writes a New Tag of an Object to Find…or Perhaps a New Object of an Array of Objects stored for say 6 Pillars of Lights that need to be turned on in a specific order. The Foot Pad when stepped on Gets the Variable on a Player then Finds the Nearest one matching that Tag Variable and…it does something. It is dynamic and fluid.

You can have Dynamic Variables at Runtime or Static Variables as any script.

Granted that the ‘Internal’ workings of what is going on in that function is going to be completely different in Aurora Engine even though both use C++…no matter. Why can there not be Blueprints already designed to Simply Get and Set information between objects. Personally I love the math and figuring out which pieces of data to Set but having to write/draw this for simply the sake of more work is nuts.

I made a very nice Persistent Time blueprint and it works very well. Getting that time and syncing it to various objects was a pain. Should be much simpler.

Thankyou all for your honest answers, if anything the fact that blueprints are a “stop-gap” between quick (simple) game creation and the wider world of programming is something that doesn’t bother me. It was watching video’s about the Unreal Engine that showed whole worlds/games created by level designers which peeked my interest (I have used lots of editors in the past (UDK included)). There was a video posted featuring a level designer showing off his new game at I think a Ted talk using UE4 and blueprints.

The biggest problem I seem to be having is, when I create a function in a function library (trying to work from memory here) which contains outputs I can bring those into a blueprint and connect my variables, say an int value. However when I call that function in another blueprint it contains no data. I gather that a function with outputs/inputs can’t carry variables across actors.

I understand your problem, will look into it myslef when i get a chance, But there is a way to expose variables publically.
For example I created a calculator, Basically a Text component, within the blueprint I have events to trigger and update the function, but that function is contained within the Blueprint, I’m sure you are able to create just a blueprint that will act like a function. Ill come back after some experiementation.

I had problems with blueprint communication as well(probably still do :stuck_out_tongue: ). I think it is an area that could use a few usability upgrades that mesh with the visual nature of blueprints. I am hoping that some day we get a project event graph where all blueprints reside and communicate that would be almost the same as your normal blueprint event graph.

Until then, you just have to figure out how to get things to talk. Cast, Interface, exposing variables on spawn, etc.

There is definately a learning curve for blueprint, example the way the connection work, & tracing which nodes get activate first,This is oppose to progarmming that you know line 2 will follow line 1.

I can imagine how it can be particularly frustrating for an experience programmer. I have been having UE4 for a little more than 3 weeks, & blueprint certainly top the list of most frustating stuff so far, after rendering.

I have mentioned before it will be good, to have a ‘conversion’ table of an equavilant node network for some common C++ operations, to get programmers up to speed in blueprint.

Many time, there are equalivent solution in Blueprint, but is not always clear (for newbies at least). A conversion table like I mention will help greatly.

I disagree however that its a start stop solution, & design mainly for non-programmer (Where programmer should use mainly use C++).

Its still young, & can be massively improved still. Its up to us end user to feedback to epic of some of the common limitation/confusion that we find, what nodes should be added, or which documentions need more details etc

there is a perfect place to learn, try to understand, try and come back when you want to try again for quite all ue4 stuff : The content example project. (And the blueprint examples too)
When i wonder something my first step in search is there and most of the time, i find solution immediatly. And when i don’t understand, i reproduce the example in another project (all examples are documented and as it is a project you have all the time you want to understand and try)

The problem I have with the content examples are they are very generic and very light on anything which can be considered learning material. The math room for example is a great example of what can be achieved with blueprints but when you actually try to follow how actor 1 communicates with actor 2 you then discover that its all contained via program rather than blueprints. The tutorials I’ve seen show “cast to” or functions storing variables, but none of the variables in the math room are shared visually.

I’m currently trying to create a topdown camera which will move when the right mouse button is held down and uses the change in cursor position to set the distance. Now I’ve managed to get it to move (read wobble) because I know I’ve done it wrong and I know why and what I need to make it work. However the “Topdown, turret defence” example which I downloaded with the expectation that “powerful” blueprints would feature heavily, only to discover that the viewport/camera movement is all controlled in code rather than blueprints.

I may look through the top-down template blueprint(s) later today (after work) and see if there’s anything I can learn about mouse position and viewport size.

You can nest a C++ code to make a node if thats the most optimum way to do things. In any case, we can feedback to Epic the issues we have with blueprint so they can improve.

As far as mouse position & viewport, do check out Rama’s plugin,

There are some nodes that you may find useful, like ‘Get mouse position’, ‘Set Mouse Position’ node, as well as ‘Viewport Size’ node, among others.

Hi Starseeker thanks for replying

I have the camera in a pawn (as I’m trying to create from scratch rather than use character bp), I’ve created a HUD bp because I initial thought if there’s no draw hud event in the project it wouldn’t give me viewport size, mouse position.

However I’ve tried to get “get mouse position” and viewport size in my Top_Down_Camera pawn blueprint and it just shows a size x and size y of 0. I can’t find a way of connected the get mouse position node to communicate with any other node. I assume I need to link it to a get player controller, but it returns no data and the tooltip says “if no hud is found returns 0”.

I can get the mouse position and the viewport size (and then /2 to get the screen center) in the HUD blueprint but I can’t cast to “Top_Down_Camera” and the function I’ve created called ViewportXY which outputs X/Y int’s from HUD doesn’t contain any data when I bring it up in my Top_Down_Camera. It always appears that when I need something to share I fail or I get a corrupted project (causing me to start from scratch).

What would be brilliant is if you look through the node menu with context turned off, it highlights what nodes can call that node. I.e if you hover over “get control rotation” it shows you a “get player controller” (obviously this could be turned on/off in settings). It would greatly allow you to “play” with blueprints rather than hunt for a guide or tutorial.

Are you using Rama’s plugin? If so, there shouldn’t be a problem to get viewport & mouse position in any blueprint. Then you will not need to use casting.

Something must be wrong, as mouse position is almost never zero (unless its out of viewport or at the top left most position).
if you have a screen res of 1920, 1080, X should be between 0 to 1920, & y 0 to 1080 (for example 400, 800)

Do note that the cursor (which usually is centered in the viewport in a first person cam) is NOT the mouse position.

Not sure you need it, but to enable mouse cursor event (like mouse click), you need to set it in the default tab of the playercontoller BP.

By default, screen size is available via the HUD event (which can be use only in HUD class). Thats why rama created the viewport size node, so we can grab screen size anywhere.

You can find Ramas Plugins here.!

This could be what you look for.

 The Set/Get Mouse Position nodes work directly with the player's viewport, and do not require access to the HUD canvas.

~ Set Mouse Position - SET the mouse position to any values of your choosing!
~ Get Mouse Position - Get the current mouse position, will be consistent with results of SET Mouse Position

~ Get Center Of Viewport - Obtain the coordinates of the center of the viewport! Works in PIE as well as standalone game instances

Hi all, well I’ve been playing around and I think I have something I’m happy with. I’ve even included a “Zoom” to the camera. Please have a view at the below image and send any critisism my way.


Have you watched the blueprint youtube video’s on the Epic channel? That tells you most of things you need to know, I will admit though that when getting variables/functions from other objects they don’t explain it very well as they like to use the quick and easy shortcut of adding it to the level blueprint which I personally think is bad practice, that should only be used for level specific stuff. The tutorials do teach a lot of bad habits in regards to blueprints, it’s easy to see why they’ve done the tutorials in this way so they concentrate on the actual specifics of the tutorial rather than explaining why you’re doing something like you’re doing. If you don’t already know what you’re doing then obviously you’re going to follow the bad practices in those videos as that’s how you’re being taught.

Unfortunately blueprints are still programming no matter what the PR line is so if you don’t have a basic grasp of object orientated programming then it can be very confusing, especially in regards to things like getting variables from other objects.

I’ve managed to do everything I wanted in blueprints without having to resort to any C++ programming yet, this includes full space flight movement and AI so trust me it is possible and not that difficult once you understand a few basic concepts.

So I’ll try and explain a few basics in regards to communicating between objects with a practical example:

One of the most common usages of getting variables and data from other objects is during runtime i.e. in game you want to store an enemy object as a ‘target’ variable so you can then do various things like for instance, get the targets location in the world. This obviously can only be done whilst the game is running so you have to do something to find and store that object in game. There’s various methods of doing this, it really depends on the situation but for this example we’re going to use a trace.

So I’ve setup two blueprints that derive from class ‘Actor’:


Then place them into the level:


In the ‘Player’ blueprint I’ve created a couple of variables that we are going to use to store the same enemy actor but each in a slightly different way, this is to show you an example of ‘casting’, it’ll make sense in a minute :slight_smile:

TargetActor - this has a variable type of ‘Actor’
TargetActorCast - VERY IMPORTANT has a variable type of ‘Enemy_C’. Basically it’s the ‘Enemy’ blueprint class we created a minute ago but when setting it as a variable type UE4 adds that suffix of ‘_C’


The ‘Enemy’ blueprint has just the one variable called ‘MyInt’ which is set as variable type ‘Int’, the default value is ‘69’.


So now the basics are setup lets do some exciting stuff…

Now just before I go any further I’m going to point out another bad practice from the tutorial video’s, they always show most things being done from the ‘Event graph’. This basically means you end up with a cluttered confusing blueprint that steadily grows in size and confusion. Bad idea, you’re better off using functions/macro’s/function libraries/ that hold the actual logic and then you just call these nodes in the event graph itself via events. You’ll see what I mean in a minute :slight_smile:

So lets create a trace function in the Player blueprint to store that Enemy.

First off create a ‘Vector’ variable called ‘EndTraceLocation’, this is basically used for the ‘end point’ of the trace away from the players position, it’s just easier to amend this variable rather than going into the function and changing it everytime. I’ve also made it ‘editable’ so you can change the value of it within the editor once you’ve placed an instance of it in the level.

You may also notice that I’m putting all the functions and variables into ‘groups’, once your list of variables/functions starts growing it’s going to get very confusing very quickly so best to group stuff to keep it neat and tidy.

Now we create a function in the ‘Player’ called ‘FindEnemy’.

-Click on the entry node ‘FindEnemy’, in the ‘details’ panel in the bottom left of the window add a new ‘output’ and set the variable type as ‘Actor’. I’ve also called the variable name ‘Actor’ just to confuse you. This will then add an ‘Exit node’ in your graph with a return type of ‘Actor’.

Basically this function does a trace which returns the first actor object it comes into contact with.

This as you may have worked out will return any actor in the world (that is in layer ‘visible’)as everything in the game world is an ‘actor’ which isn’t really what we want in a real game situation, you can narrow down what the trace will pick up but that’s a whole other topic that we won’t get into now, just bear in mind when doing this for real you’d want to set up traces to work more efficiently than this by using ‘object types’ and ‘collision channels’.


Before we run our first test go into the ‘defaults’ tab of the ‘Player’ blueprint. Under the heading ‘Input’ set the ‘Auto Receive Input’ as ‘Player 0’. This is just an input hack so we can run input against this blueprint without creating controller class’s and all that sort of stuff. Useful for testing stuff but you don’t want to use this in game really :slight_smile:


Back into the ‘Event graph’ of the ‘Player’ blueprint, create an event for key ‘F’. Drag your new function ‘FindEnemy’ into the event graph and hook up your ‘F’ key event. You see how now you’ve put it in that function your event graph is only two easily readable nodes rather than an absolute mess of wires and rubbish all over the place :slight_smile:

I’ve also attached a print string after the ‘FindEnemy’ node so you can see what the value is printing on the screen.

event graph.png

I’ve done this test in a blank project so my actual player is just the floating first person camera, might be easier to use this for the test if you’re not doing so already. Anyway so lets hit ‘play’, move your player/camera so you can see both the ‘Player’ and ‘Enemy’ blueprints at the same time, then hit the ‘F’ key.


Now I honestly cocked this up on purpose (honestly) to show you that the trace will return any old object as we’re tracing by actor, see how the print screen is printing the value ‘floor’ as that is the first actor the trace hit.

So move the Player and Enemy blueprints a bit higher on the Z axis so the trace won’t hit the floor and run the test again, press F and see what the value printed is now (if like me you’ve been in an idiot and positioned the Player blueprint further down the X axis than the Enemy you’ll have to set your ‘EndTraceLocation’ to a minus value to get the trace to go in the right direction)

trace success.jpg

There we go it’s returning the ‘Enemy_C_1’ object now which is the unique name for that instance in the game, so if we store that value in our ‘TargetActor’ variable in our ‘Player’ blueprint we could then use that variable to get specific data from that particular instance of the ‘Enemy’ blueprint.

So let’s do that, open up the ‘Player’ blueprint and add a ‘set’ node for the variable ‘TargetActor’ and hook it up to the ‘Actor’ pin on the ‘FindEnemy’ node in the event graph.

I’m going to kill two birds with one screenshot here…in regards to getting the debugging information on the blueprint to look at a specific instance, whilst the game is running just choose the instance you want from the drop down box I’ve highlighted called ‘Debug Filter’. As there’s only 1 instance in this example you’ll probably find that’s been chosen automatically anyway.


So now you have stored a reference to that particular instance in the game you can now access it’s variables and functions!

but…and here’s where ‘casting’ comes into play, because your variable type is an ‘Actor’, it can only access the variables and functions from the class ‘Actor’, not any custom variables or functions that you put into the ‘Enemy’ blueprint itself. This is your object orientated programming, the Actor class is the parent class, Enemy is a child class of Actor, so Enemy has all the variables and functions passed down to it from it’s parent, so if your variable type is ‘Actor’ then it can only access the variables/functions on the parent level.

Lets do a practical example to demonstrate the above waffle:

In the ‘Player’ event graph place a ‘get’ node for both ‘TargetActor’ and ‘TargetActorCast’.

Click and drag from the pin on the ‘TargetActor’ node and type "location’ into the search bar (make sure you have ‘context sensitive’ ticked).

You should see a list like my screenshot where under heading ‘transformation’ you’ll see nodes like ‘Get Actor Location’.

location - target actor.png

Now do the same for the node ‘TargetActorCast’, type in ‘location’ again and you’ll see the same list of available nodes. This is because class ‘Actor’ has these variables/functions so therefore the child class ‘TargetActorCast’ has them also.

location - target actor trace.png

Now…to turn it around…click and drag the pin from the ‘TargetActorCast’ node and type in ‘MyInt’. You’ll see the options to ‘get’ or ‘set’ the variable ‘MyInt’ that you created in the ‘Enemy’ blueprint at the beginning of this massive waffle. So there you go, you can easily access variables from another object.


Now try the same with the ‘TargetActor’ node and you’ll see that it can’t find that variable ‘MyInt’…because it doesn’t exist in ‘Actor’.

Hope this is making sense now :slight_smile:

actor level - myint.jpg

So therefore sometimes you might want to just store a reference to the instance in game as ‘Actor’ as you only need to access the variables from the parent ‘Actor’ class. Sometimes you’ll want to store the instance as the child class itself so you can access the variables and functions you’ve created within that class. This is when you do a cast.

So back in the event graph of ‘Player’. Drag the ‘Actor’ pin from the ‘FindEnemy’ node and type ‘Enemy’. You should get a node saying “CastToEnemy”. Whack that in there, from that cast node you then set the ‘TargetActorCast’ to store the Enemy. So that cast is basically checking that the Actor class is the sub class ‘Enemy’. For instance you could create another blueprint derived from Actor, call it something different, run the same as above and get a reference to it with a trace. You will be able to store it in your ‘TargetActor’ variable but when you run the ‘CastToEnemy’ it will fail because it’s not variable type ‘Enemy’.

cast to target.png

One last practical example using what we’ve already done, lets run a function from the ‘Enemy’ blueprint but we’ll call it from the ‘Player’ blueprint. I bet you’re struggling to contain your excitement by this point…

Open up the ‘Enemy’ blueprint and create a new function called ‘PrintMyBitchUp’ (you can tell I’ve lost the will to take this seriously anymore). This function will just print the value of the ‘MyInt’ variable. I’ve also created a string variable that will get added to the print log to make the log a bit more meaningful on the screen rather than just a number.


Go back to the event graph of the ‘Player’ blueprint. Add a new event for the key ‘G’ and then put a ‘get’ node for the variable ‘TargetActorCast’. Click and drag the pin from the ‘TargetActorCast’ node and type ‘Print’. You should see the function ‘PrintMyBitchUp’ available in the list! Click on that to add the node and then connect that up to your ‘G’ event.



Nearly finished don’t worry…

Play the game, now before you hit the ‘F’ key to fire off the trace, press ‘G’ first, see how nothing happens? This is because currently the ‘TargetActorCast’ is ‘none’ because you havn’t stored a reference in there yet. So hit the ‘F’ key to fire the trace to get and set the ‘TargetActorCast’, now press the ‘G’ key. You should get a print log showing that the function from ‘Enemy’ has been ran by being called from the ‘Player’ blueprint!


Hope that all made sense and hopefully helped you understand accessing variables and functions between blueprints. Any questions feel free to ask and I’ll attempt further waffling.

Hi Savage, wow thankyou for all that information. I shall refer to it as often as I can.

From reading through it, I think I may have worked out why my variables weren’t showing up and I was getting “no debug data”, my function was getting passed over, however it wasn’t connected correctly inside the new blueprint. Therefore it wasn’t being called. Very hard to get information when things aren’t called.

Become good friends with print string. Put it everywhere you are having problems and you will know exactly what is and is not working.

no problem, I know it can all be a bit confusing when you first start out, especially casting and getting variables/functions from other objects. Maybe I should put this in it’s own thread, although not sure I can face inserting all the screenshots in the right order again :slight_smile:

Just edit your post then copy and paste it into your new thread. :slight_smile:

Good idea :slight_smile:

Done and put up in the tuts section

I hope someone will also rename the thread.