Weapon Inventory System

Hello guys.

I’m making a Weapon Inventory, so that the FirstPersonCharacter can collect his weapons and switch through them pressing the corresponding key on the keyboard.

Now, I created a Base Class (called Weapon) and a Derivated Class from it (called Minigun).
I’m gonna use the Minigun as example for my purpose.

I created two variables on the Character: OwningWeapons (array of Weapon objects) and ActiveWeapon (Weapon reference object).

I then created some functions on the Character: AddWeapon, CheckAlreadyOwning, AddBullets

I’ve troubles in AddWeapon function.

How do I create a new Minigun object?

This is what I did for the moment:

AddWeapon

As you can see, at first I check WHICH weapon has been taken. In this case, I check only for the Minigun.

If the Minigun has been taken (second Branch) then ADD to the Weapon array a new Minigun object

In one side I have the branch, in the other I have the ADD Function (linked to my array of Weapons)

My question is: how to create a new Minigun object and link it to the ADD Function?

I tried using Construct Object From Class:

But when I compile, I get those errors.

What is the OUTER and how to use it? Thanks!

Outer is like owning/parent object, for example in case of component outer is actor class where component is contain and some function like RegisterComponent don’t require you to point to actor you want attach component to, it get it from outer varbale. Kind of odd it is required.

Get “Self” node and plug it to outer, weapon is owned by player character either way

I added a Self reference, but I still get error

Is minigun a actor?

Yes, it is. It derives from Weapon (which is an Actor class too)

You should use Spawn Actor insted then Construct is for non-Actor objects

In this way, I can’t add the Minigun to the Array