How do I clear a variable?

Very sorry if this has been asked before, but I couldn’t find an answer.

How do I set a variable to nothing/nil/null/none etc?

Scenario: I set a variable on an actor when it collides with another actor, I want to clear that variable once it’s done colliding.

Thanks

You can try to set the variable without an input parameter ?

1 Like

haha, yep, that was it. Simpler than I thought!

hey guys
this didnt work for me
im calling Set variable, and passing nothing but it wont work…
am i missing something ?

What type of variable are using?

im trying to set a reference to a Volume to None

Have one volume variable you use to store your volume. Then have another volume variable that is never set to anything. Us the second variable to set the first variable to None.

that doesnt sound very good
should i raise a request to have a None variable?

I would like to know how to clear a reference variable too.

Worked for me! Intuitively intuitive

Precision: you need to connect an empty ‘make array’ node to the set array variable

This is an old thread but since there must still be some people here looking for answers, there is a workaround for this.

I’m guessing the problem lies with Actor references or something along those lines. The first answer from this thread was partly correct. When trying to clear a reference, you should set the variable without an input. This does clear the variable. But not entirely. There are still some traces left, for example the coordinates get reset to 0, 0,0.

To counter this, make a branch, type “==” and get the Equal(Object). Leave the select asset clear and the branch should be able to tell if the variable is in fact empty or not.

Good luck guys, this worked for me, hopefully for you guys too!

1 Like

whoa. that’s a really friggen good idea!

Thank you so much for this! I was having issues with my ANIM GRAPH where it would skip one state the second time I fired the animation loop.

My states were setup as → idle with bow equipped → aiming bow → charging bow → firing arrow → idle with bow equipped.

It worked the first time I tried to shoot an arrow, but when I tried again, it would skip past “charging bow” state and right to the “firing arrow” state. Turns out I had to set the boolean variable I used for checking if the arrow had been shot (is arrow shot?) to untrue again after the arrow was shot in my player controller bp and hook the “is arrow shot?” variable to == (equal) and leave the bottom variable of the equal to checked (true).

I attached some photoes incase this can help someone too!
Took ages to find this fix for me :smiley: So thanks again !

ive found that there is CLEAR node to empty array