Is casting expensive?

A good thing when optimizing stuff is to cache those objects you need a lot, will safe you those casting that you do over and over again. For example casting to a specific weapon type from the base engine type, you could hold a casted cached value and change the cache when you switch the weapon or drop it. Same applies for the typical Pawn <-> PlayerController relationship.

But I would only doing it if its totally logic in a specific point or easy to do and to maintain or if you are really seeing some peaks when profiling. Take into account that caching gives you also headaches when the cache is not invalidated properly resulting nice bugs :smiley: