Avoid UObject factory for blueprint?

Hello,

As it appears, UObjects and derived types are manipulated only through pointers in blueprint, however when creating a variable, it only really creates a null pointer.

Therefore, if you want to create one of your objects, it seems like the only solution is to implement a factory, much like what is described in the following wiki page :

While this works fine, it is a bit tedious to use and not necessarily obvious for a non-programmer doing blueprint scripting. It also seems logical that, since unreal has introspection and reflection of the derived C++ UObject types, it should be able to expose allocating and creating a UObject without any manual work from the programmer.

So is there another way than creating and exposing my factories ? Is it possible to locally instanciate an object and set its values as a variable or component of my blueprint with available tools, or do UObject always have to be dynamically instanciated in the event graph with factories ?

I was looking for a way to create objects type of classes derived from uobject on runtime too and just found this code snippet to add that functionality. I’m really curious about the side effects of it because epic doesn’t give this feature as default on blueprint. Can someone explain why please?

Agreed, I can’t imagine I’m the only one wondering about this, but never really got a reply. It seems like we generate enough reflexion/introspection code to be able to construct our UObjects without having to call our own code just to call “new”.

There must be some kind of system that I’m missing, it just seems like the first thing one would look for.

I thought i miss something at first but after researching and trying lots of thing, i realized this is the only way to create it. Why would epic block something like this? If it’s because garbage collection, what we should be careful about while using this?

I don’t think it presents any danger, other than a mild annoyance. But it’s also counter-intuitive in the hand of an artist editing a blueprint, when they create a variable of your UObject type, they’d expect to be manipulating an instance of that object, not a (potentially null) pointer.

Would love an official answer on this :slight_smile:

Still really want to hear the reason from Epic, why this is not default feature for blueprints?