AnimBP Casting on Event Begin Play VS On Update Animation

I know that casting constantly impacts performance, but it seems like in every single tutorial casting in the AnimBP is happening constantly on the update animation event. Why isn’t casting on begin play used and why is the casting happening on the update animation?

There used to be an issue where begin play for the animation BP was called several times instead of just once.

You are correct that casting over and over is superfluous in most cases.

Essentially OnBeginPlay for animations wasn’t working as expected so the value could accidentally not be set by the time the update animation event was called.

Also, your try get pawn owner shoud sport an IS Valid? Node prior to the cast.
No need to cast when there is nothing valid to cast with - in both cases.

To see if the animBP on play has been patched, add a print string at the end of it with a time of 10sec.
if you see more then one entry appear for each relevant actor on screen then the issue may still be present.

If you see this occurring, you can add more print strings to the rest of the items. the character BP, the level BP, the Game Mode, the Player Controller, etc. To see the order the stack gets built in.

if I recall correctly, the player character BP begin play occurred after the anim BP one, therefore any cast resulted as invalid - no player character was present to check against.

Thanks this was very helpful!

For the record the Event begin play no longer exhibits that problem it seems.

1 Like