Search code examples
unreal-engine4

Add to array as value, not reference


Trying to add a class to an array. The class contain an object and an integer. However, when I destroy the SELF the class reference in the array is removed as well? How do I add by value?

enter image description here


Solution

  • UObjects are inherently a reference semantics entity. Their lifetime and memory management is controlled by the engine.

    It sounds like HerbType should be a class reference, which you would spawn when necessary.