Check if variable is set

I’m trying to do a couple of related things with a blueprint with no luck…

  1. Check to see if a variable is set.
  2. Unset a variable, or set it to null.

Any thoughts on how this could be done?


1 Like

By check to see if a variable is set, you mean if it has a value during run time? You could hook it up to a print string node or you could right click on it in your blueprint and select to watch the value (you’d see its value inside your blueprint while playing in the editor).

You can set a variable to null or unset it, alt-click on the variable and drag it into the graph to produce a Set Variable node which you can specify what that value is. You can look at this section for more information: Variables


Thanks Wes… I’m talking about runtime… Ill elaborate a bit.

My main player Pawn has a variable called ‘CurrentMission’ and this should point to a specific type of Actor. I have this part done.

At certain points in the game, the player can accept a mission ONLY if there is no ‘CurrentMission’ set. So this is why at runtime I need to check to see if ‘CurrentMission’ is set and ‘Branch’ my functionality.

Related to this, once the user has completed the mission, I need to ‘Unset’ the ‘CurrentMission’ variable.

Make sense?



We have a “IsValid” macro that checks to see if the variable has a null reference. This sounds like what you might want!

Fun Fact:
Double click on a macro to open it up and check out what it’s doing under the hood! Eg. IsValid, DoOnce, Gate, ForLoop etc. etc.

You can make your own macro libraries like this to make your life easier on common tasks.


Thanks, exactly what I need!

What about setting a property to null?

Was just wondering this myself, every helpful thanks!

If you leave the value pin disconnected on a Set node, that will set the object to null. We don’t have a null literal node, though that wouldn’t be a bad idea to add.

Michael Noland


Thanks Michael.

I don’t like trusting the nulls, as I can’t be sure if I MADE it a null or if it just never got initialized. If I want something set to nothing, I make an instance of that class called ‘NullWhatever.’ In your case you could make an invisible actor called ‘NullActor’ and set your target actor to that on begin play and whenever you wanted it ‘cleared.’ Then use a branch that references CurrentTargetActor equals NullActor…
My 2 cents.

Michael, I’m trying to set an object to null just as you described (disconnected on a set node), but this doesn’t seem to work.

As a workaround I’ve had to create a duplicate variable of the same type which is never set and use that to signify null. I’m using the macro ‘Is Valid’ to check as well.

Any thoughts on the below image?

Gentle bump, anyone know why null comparisons don’t work given “Select Asset” is supposed to be equal to null?

This is an “interesting” example, as I don’t think most people would do it this way.

  1. OnComponentEndOverlap OtherActor should be something that’s moveable/player controllable, and you want to set it to null directly which is odd.
    (if any events are currently running, I don’t know what the implication is with UE4.)
  2. If you want to set currentMission to null, isn’t it suppose to be a variable that pulled from test character, but the set node would be target=TestCharacter_C.currentMission, and select asset is empty(select asset).

just to offer my observation.

Sorry I think the naming convention I’ve used in the image has proved confusing - I’m certainly not setting the player itself to null.

In the first image the ‘other actor’ is plugged to ‘player character c’, while what is being set to null is a variable ‘test object variable’ (which is a variable belonging to the object ‘player character c’)

In the second screenshot I’m getting a variable named ‘NULLObject’ from the player character and setting that onto the 'test object variable. NULLObject is a dummy variable that is never ever set and thus holds null inside of it. This ugly workaround is precisely needed because “Select Asset” doesn’t seem to equate to null for the test object.

(in hindsight I should have left the original names from my blueprint instead of this generic example)

maybe it’s a bug, congrats! :stuck_out_tongue:

Hah I’m just surprised this hasn’t been widely reported before. I’ll try logging a bug in the Answers hub.

This thread on the answers hub discusses the exact issue without resolution while another one is marked resolved but only the part where you use “Select Asset” to check for null works. i.e setting an object to “select asset” itself doesn’t see to make it null.


This does seem to work correctly for me, the following snippet prints out:

[3061.28][314]LogBlueprintUserMessages: IdleCycle1
[3061.28][314]LogBlueprintUserMessages: None

Michael Noland

@michael, I think VSZ is referring to set variables with a reference. Regular set var work as intended with object var.

Quite bizarre, I tried the same setup that Michael used and I’m still able to reproduce it. Maybe it’s worth mentioning the object in my case is a blueprint instance so I’m not sure if there’s something related to this that’s triggering the issue.

Either way not a big deal as I have a workaround to move ahead, will be interesting to learn what’s happening though.

LogBlueprintUserMessages: BP_PolliPlant_Greater_Knapweed_C_0
LogBlueprintUserMessages: BP_PolliPlant_Greater_Knapweed_C_0

It might have something to do with the use of “self”.