Hi, so there are few points/differences here:
-
References. Functions like “GetActorOfClass”, Cast to, etc create hard references between actors. It means that when one actor is loaded to memory, another actor has to be loaded as well. For small project is ok, but generally it’s not a good practice.
-
Interfaces are great when you want objects to react differently to the same event. For example Interact. If you use interface logic could look like: Trace to get actor in front of the player, send “Interact” interface message, object does it’s logic (if it’s door they will open, if it’s lever it unlocks something, etc). Without interface you would need to cast that object to all classes individually (cast to door->open, cast to lever->unlock, cast to … etc).
P.S. GetActorOfClass / GetAllActorsOfClass is very heavy function. It loops through all actors from the level… so imagine how it will lower your fps count in bigger level if it’s used somewhere in Tick.