Efficient Ways of Referencing Game Instance/Mode/State Classes

Hello,

While developing in Blueprints, I find myself constantly casting to set references to the game mode, instance, and especially the state. I do this on BeginPlay for actors, widgets, and other classes.

Is there a better way to access these classes than casting for them every time? I’m worried this is very inefficient.

Any advice would be appreciated.

Cheers.

Casting can get expensive, so doing it once and creating a reference var is a good route to take. I take the same approach everywhere I can.

How? There is nothing expensive about a Cast it is just a simple function call. You can make a function in a FunctionLibrary that do the Casting for you then you don’t have to Cast, save and manage variables everywhere.