Improved pointer checks

29th September 2022


Tonight I was having trouble with a simple reload function in my game. The function was working last tonight, but tonight pressing "reload" nothing happen. No errors, but no client animation.

After 5minutes, I traced the issue to this line:

if (IsValid(AnimInstance) && IsValid(ReloadMontage))

Turns out that for whatever reason my Reload Montage had become blank in the Editor. So this means that with no montage set, my function would not trigger reloading. I still dont know how/why the montage became blank when it was previously set, my theory is one of the editor crahses caused it.

But the silent failure meant it wasnt obvious to me.

Instead its far better to use asserts during development, to help prevent silent errors:

check(AnimInstance)

This way I'll instantly know during development if something I expect to never be null is wrongly set - and I can focus on fixing it immediately.

< BACK TO LIST