Construct Object From Class vs Spawn Actor?
I've been wondering what the exact differences in behavior between the two are.
I know that spawning an actor technically creates an object in the world, and that constructing an object does not. What I'm curious about is garbage collection. When spawning an actor I can remove it using the Destroy Actor node, how is that handled for objects? Do they automatically get purged from memory once there are no more references or is there something I'm missing?
Also, spawning an actor allows me to pass certain variables (apart from location/rotation etc.) like you would pass variables in C++ when instantiating an object (-> constructor). I've not been able to replicate that when constructing objects from a class, so I was forced to make a separate "construction" method within the class. Is there a way to avoid that? I.e. allowing for proper construction arguments?
I've not been able to find anything regarding those issues, but if I've missed something, I'm sorry for double-asking.
Thank you for your help!
asked Jul 05 '17 at 01:15 PM in Blueprint Scripting
Yes UObject gets Garbage Collected if not refferenced anymore. As far as passing Arguments thats a Complicated story you better of creating a simple Init Method with the Parameters you want. If you want to have the Inputs avaivable in Blueprints add
to any variable. They will show up in the Construct Object node automaticly.
answered Jul 06 '17 at 12:13 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here