Download

Issue with Weapon Inventory

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.

861e22d0b948b8b08d5668ece78a9073817a38ca.png

How do I create a new Minigun object?

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

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

I tried using Construct Object From Class (as you can see)
But when I compile, I get those errors.

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

The outer is the “owner” of your created object. If that is in your pawn, you should probably get a reference to self and plug it in there. But it seems minigun is an actor and not an object? You don’t construct actors like that, you spawn them.

I’m creating an Inventory of Weapons.
So, the OwningWeapons variable is an Array of objects of the Weapon class (thus, an array of actors).

I wanna add to the array a new Minigun object

Any solutions?

The question does not fit the theme , but aknnst you tell / help as you’ve done the inventory me ?

Whaaaaaaaat?

Set the minigun actor to data-only, then add mesh to that data

Add a current weapon mesh to character, then change it to Spawn Actor From Class and spawn it anywhere and make it ignore collision
Then read data from it and set it to your character’s mesh component

I personally didn’t like the idea of ‘resizablility’, so I simply made a struct with the class variables, and the objects as loadout, and inventory

And enum EWeaponSlot to use in EquipWeapon(), MakeWeapon(), CurrentWeapon, etc.

Alright but

Set the minigun actor to data-only
How?

It is a question :).

Yes and I didn’t take it