Announcement

Collapse
No announcement yet.

Create UObject subclass from blueprint (not AActor subclass)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Create UObject subclass from blueprint (not AActor subclass)

    I made a blueprint class to store some data in it, nested directly from UObject (or, as it is displayed in the blueprint creation UI, just Object). I also made it implement some blueprint interfaces and added some variables to maintain internal state.

    Now, how would I use it? By using, I mean how do I instantiate it and pass it to somewhere? Like in a LevelBluprint, in construct script or in OnBeginPlay event, I want to create some instances of my class (lets say class name is MyItem) and add them to an array, which is stored in a level blueprint.
    Also, I don't quite understand what would the scope of such object be. Will it exist during the level lifetime, or will be refcounted, or will it just leak? Or there is just no way to instantiate any non-spawnable classes from blueprints?
    Also, how does the ownership works with UObjects and AActors? Who owns an instance of AActor subclass when it gets spawned? And how are they passed around - via references?

    And, maybe not relevant to here and more like legit C++ question: are blueprints thread-safe? How to maintain thread-safety in the engine? It is multithreaded, right?

    #2
    I don't belive blueprints support creating basic UObjects without some custom code.

    Comment


      #3
      As I can tell so far, you can only spawn stuff from blueprints, thus meaning that only the instantiation of AActor subclasses is possible via blueprints. This sucks. I just thought maybe there is some hidden or unobvious way to do it. Why is it that you cant create an arbitrary subclass of UObject via blueprints? What was the motivation for such limitation? It seems pretty straightforward to implement, except for the scope and ownership, as I mentioned above, but that may be just for me cause I may be lacking some knowledge about the engine internals.

      Can anyone explain this please? I think I'll implement custom blueprint node for this, however, it seems I'm missing something, something that blocked Epic devs from implementing it in the first place.

      Comment


        #4
        Hello,
        Maybe this link will have infos you can use to expose variables and use functions from your UObject to blueprint : https://docs.unrealengine.com/latest...nts/index.html

        Comment


          #5
          Well, this can easily be done with C++. The question is can this be done with codeless project (blueprints only project).

          Comment

          Working...
          X