Object Oriented Weapon System

Dear reader,

I am trying to build an extension to the First Person Template, making it easier to change the weapon used.
My Idea was: Create an Actor Blueprint Class called Weapon, and make every weapon used in the game a Child Instance of this blueprint, so that events like"Fire", “Reload” etc. can easily be called by the character blueprint
and the appropriate method for each weapon could be called immediately.
However, once I add the “Weapon” variable to the character blueprint (replacing the Rifle Skeletal Mesh), I kinda get stuck. I can’t put in a default value for my Weapon Variable (“Editing this Value is not allowed”), nor can I set a child blueprint of the Weapons class as default, or used weapon,
for they are also “empty” instances of the Weapons Class, even though they’ve got their properties assigned.

When I try to attach the “Gun” Skeletal Mesh (Base property of the “Weapons” class), as other skeletal meshes would be attached to the character mesh as seen in the FPP template, I get these errors:

Error Accessed None ‘Weapon’ from node AttachTo in graph ‘UserConstructionScript’ in blueprint PlayerController
Error Accessed None from node AttachTo in graph ‘UserConstructionScript’ in blueprint PlayerController

I’d appreciate any help with solving this issue, or an entirely other way in which I could make an easy, widely usable weapon system. Because I am thinking about using around 30 weapons, Trying to cast my “Weapon” to each different weapon instance actor is not an option.

Thank in Advance, any help is welcome.

My first though is - I am not sure you need a class per weapon.

I have a an item class, from which I have a gun class. This allows all items to have properties like weight, icon, skeletal mesh etc etc. Then I have the gun class allows for specific gun orientated properties like ammo type, rate of fire etc etcand actions such as what happens when you fire a gun.

Then I pramartise the different guns, so all guns are type gun (gun class), but upon creation I set different ammo types and rate of fire.

I think you are getting editing not allowed - because you’ve not allowed editing in the class where the variable is defined.

I hope this helps… if not explain further and I’ll try again :slight_smile:

Regards W-Jones

It generally pays off to check the dates. You’ve necroed a 5 yo thread of a user who’s been inactive for 5+ years. Looks like they’ve posted this and we never seen them again…

1 Like