Dilemma with Destroy Actor

in programming term, cast a “class” does not make any sense. you can cast one instance(object) of a class to another(usually from classes that you inherited).

back to the dilemma, what I would do is:

  1. like any other games with inventory, start assign object id with unique int.
  2. in your base class, build a big Enum that contains one type of objects, multiple of them if you have different types.
    ie( 0~1000, misc items/ingredients; 10000~19999, weapons, 20000~29999 armors, etc. )
  3. have a static event that spawn item base on id, preferably from a item spawner blueprint to avoid bp compiling dependencies.
    (so if you add any new item to enums, you just recompile item class, base class, spawner class in sequence.( don’t do the castTo in base class. )

reason for not cast to child inside base.(you create real loops)

  • any change to base, you would need to recompile child
  • any castTo to non-native class, of the cast target bp changed, you have to recompile current bp that does castTo.