Engine crashes when spawning projectile

Hey everyone. I came across a problem during this video and thought I’d share my solution here for anyone who has the same issue as me. After some refactoring of code in the next video I started getting engine crashes. Turns out that the setting of the Projectile Blueprint in the Tank_BP in engine had reset to none (as a result of some refactoring) and this was causing the crashes.

I’m not comfortable with such a serious crash happening due to such a minor oversight, so I’ve gone with this as the if statement in the ATank::Fire() method:
if (Barrel && ProjectileBlueprint && isReloaded)

Now the game won’t crash, even if you’ve failed to set the Projectile Blueprint in editor.

I’m using 4.18.2 in case that’s useful to know.

6 Likes

Thanks!! Saved me there!

Privacy & Terms