[Bug] Unable to clear object variable

Hi.
I have reproduced a case where I’m unable to clear (set to None) an object variable with the Set variable function. Usually I use the Set function without setting the argument, and it clears the object. When when calling Set from inside a method, if the variable is of the same type as the BP class itself, the this pointer seems to be used, instead of None.

In this example, TestActor has a PointerToOther variable, with type TestActor. As you can see in the screenshot, if I leave the argument to Set empty, it gets replaced with the this pointer (TestSettingAndClearing v1). If instead I create an empty local variable (named NullPointer) it works (TestSettingAndClearing v2).

Unless I’m missing something very fundamental, this looks like a bug

Could someone from the staff confirm the bug ?

Hi trethaller,

What are you using for your test actors? As of yet I have been unable to reproduce this effect. If I can set up the blueprints with the same or similar pieces as you have here, I can potentially reproduce this on my end. Thank you!

I just re-reproducted it with a BP deriving Actor. The method has to be defined in the BP (doesn’t happen if the set is called from outside). I’m on 4.2.1

Howdy trethaller,

Thank you for your bug report. I have been unsuccessful with a repro after setting up the Blueprints.Let me know if you see something that seems out of place with the way I have set up the Blueprints.

After setting up these Blueprints, I am only able to see:

9613-pointer+set+to.png

Just let me know if there is any steps that I am missing.

Thanks and have a great day!

It looks similar so I’m not sure - I got the bug by deriving from Actor or Pawn.
Here is an example (goes to Content\Blueprints\Test\TestActor.uasset). On the official 4.2.1 with the setup above, the variable is not cleared.

I also get it when using PointLight as a base class.

Hey trehaller,

What template are using when you see this error (ex: top-down, first person…)? Also, have you tried this on more then one template by chance? If you have not, don’t worry about it, just let me know so I can.

I am able to see the test actor text appear when I use the top down template but not on the First person template.

Thanks!

I’ve tried on my own project which is an empty C++ project

Howdy trethaller,

Thanks again for your bug report. After attempting to repro this issue a couple more times, I was successful with the steps that you have provided. I have entered this bug into our database so that it may be fixed in a future build.

Thanks and have a great day!

Good to hear, thanks!