Download

"OnConstruction" is not triggered when dragging my C++ actor around the level. Seemed like a bug?

I’m using 4.8.1.
Editing location through property panel does trigger the “OnConstruction” method, but dragging in the viewport does not.
Am I missing some setting or just it is a bug?

I think in C++ terms that’s actually not a bug, but I’m not sure…

Editing through property panel and dragging leading to different results doesn’t make any sense.

Have the same problem, using 4.8.2.

Ohh okay. It might be that when you set the property, it triggers ‘PostEditProperty’ and possibly re-creates the object or runs the constructor from there. Dragging in the viewport might just be a more simple SetWorldLocation. Honestly, I’m not sure without checking but that’s where I’d start looking.

I do know that you can drag blueprints around in the viewport and it will fire off the construction script, though.

i was curious about this.
Say i wanted a bool, and when true it would add a static mesh component to the actor.
In blueprint OnConstruction this would be easy and changing the value would result in the mesh appearing and disappearing.

How can i achieve a similar result in C++, i have tried using PostEditProperty.