Ratchet and Clank Guns, Mechanics and Gadgets

Hey there,

just a small tip for the on-going coding stuff of your Tutorial.

Make more use of the “IsValid” node!

It can always happen, that a Reference Variable is Empty.

2 Examples, where you should use the “IsValid” node:

  1. When pressing “Fire” or “AltFire”. If by any chance, the Weapon is not Valid at the point the Player pressed the MouseButtons,
    the Game will crash with an “AccessViolation”.

  2. When spawning the Weapons at the BeginPlay, you spawn 8 of them with the For Loop and then Call the Equip function.
    Instead of needing to set the “CurrentWeapon” BEFORE calling the “GunEquip” Event, you just add an “IsValid” Node to the “CurrentWeapon”
    INSIDE of your “GunEquip” Event. And only if that’s valid, you do the “Detach” and “Visibility” Stuff.

That’s way better than assuming that the “CurrentWeapon” is set.

Otherwise, good video so far. Might wanna take some speed out of it and explain a bit more if needed. (: