Dynamic Casting Best Practice

AActor is a very high-level class. It can be potentially be everything that is placed in the world.
Casting is a necessity to determine it’s actual type.

However, there is the alternative of Components. You can just use GetComponentOfClass<T>() to retrieve a Component and use the Component to execute your logic.
This is type-safe (but not null-safe of course). It is also questionable whether this is faster than casting (prolly not)

1 Like