Reference calling and casting

I make frequent requests to

get owning player controller, get owning pawn etc and im casting them on tick

I have yet to see any impact but I’m not really at that stage - just wondering, is this super bad? what is else doing, on a tick pull them to local variables cast once? or dont worry about it?

Hi BPANDREW,

That all sort of depends on what you are trying to accomplish. Casting on Tick is not particularly performance friendly, but that is more Tick’s fault than anything else. Overall it will not cause many problems as much as it increases the potential for lag. If you only have a few of these occurring, then you are probably fine; Get too many going at once and you may see some issues. Depending on your machine “too many” can vary.

Casting once and setting a local variable would be useful in some situations for sure. In others a BP Interface could be better.

Another thing to consider is that Tick Events are based on frames. So if two players have different FPS, it will trigger at different rates.

Let me know if you have any other questions.