Converting the existing gun

Opening up MasteringWeapon.h and .cpp, let's add some variables as UPROPERTY items again, and our goal now is to replicate what is currently done in MasteringCharacter in our weapon and then remove those items from the character class. As a reminder, the things our weapon needs to contain are as follows:

  • Gun Offset (FVector)
  • Fire Sound (USoundBase)
  • Fire Animation (UAnimMontage)
  • Projectile Class (TSubclassOf<class AMasteringProjectile>)
  • Weapon Mesh (USkeletalMeshComponent)
  • Muzzle Location (USceneComponent)

At this point, as we have a bit of code work to do and don't want to be hot-reloading a lot, I recommend shutting down the editor until we're ready to add a new instance of MasteringWeapon to the game. So, let's ...

Get Mastering Game Development with Unreal Engine 4 - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.