O'Reilly logo

Mastering Game Development with Unreal Engine 4 - Second Edition by Matt Edmonds

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Back to code to finish up

Having everything set in the editor and level, we have a few more code changes to make. First, we make some changes in MasteringInventory.h:

USTRUCT()
struct FWeaponProperties
{
        GENERATED_USTRUCT_BODY()
 
public:
 
        UPROPERTY()
        TSubclassOf<class AMasteringWeapon> WeaponClass;
 
        UPROPERTY()
        int WeaponPower;
 
        UPROPERTY()
        int Ammo;
};

We add this struct to the very top of the file, just after the #include header section. We will use this in the inventory list to reference weapons from now on, instead of referencing the MasteringWeapon class itself directly (but, of course, this is now a member in the struct for our use). We use the struct to track two new properties we associate with weapons: ammo and weapon power.

Next, after ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required