How do you set a variable to null in the Blueprint Graph?
My character has a reference to an ActorType in the world. It starts out null, but when hits the trigger overlap of the object in the world it is set on it. That part works correctly,
But, on leaving the overlap I want to set the object to none. The breakpoint hits, but the variable value is not changed to null, it remains the same as before.
Going to the trigger overlap of a different object works, it is set to the new object. ,This is what I have now.
You have to set a variable at some point, whether that is using a node that says “Set Variable = Null”, or using a “Set Variable with no input” or “Set Variable with Non-Set Variable”. It is all the same thing.
Well even if you code it you would have to set it to NULL and NULL is a defined variable. So in a way its the same you have to have a defined variable that equals something or err nothing in this case.
which was what I had hoped the screenshot was trying to show sorry if it was not a good example. But I am with you on this Zeus you have to set it to SOMETHING be it NULL to start before you set it to a usable value.
Your function is lacking the input. That isn’t what I am saying. The variable that goes into that function has to be Set somewhere, and that Set node needs to be blank.
Obviously you can’t do that inside the function or it would mess with the begin overlap side as well, so just do it before it enters the function.
Yeah I used to wonder why there isn’t a Null function as well, but it is all the same in the end. Maybe the devs could put a little extra note that says no-selection/input = null.
I think some kind of explicit set to NULL and check for NULL is pretty important. I tried using an unset variable in my class named NullActor as a hack to have a way to set/check for NULL but I don’t think that works in object =. Why not have an explicit NULL if hacks are likely to confuse people? Great question; curious why Epic hasn’t responded to this one. Makes me wonder if it’s time to just go for C++ directly instead of blueprint.
Seriously? This discussion is from 2014 and there is no better solution than this? How in name of God, Epic never felt the need to set a variable to null?