Attaching a C++ Weapon?

Hey guys!
I’ve just started working on my game, and I’m new to both Unreal and C++, but I am a programmer.
I’m wondering how I should design a weapon system…
In other words, how can I have a “weapon class” that allows a “gun” or a “sword” to attach to a player or npc. This would allow each individual weapon to be developed completely separate from the player/npc. In other words, I don’t wanna hard-code weapons into the player or npc.

In other words, a “gun” component thing would hold:
-A gun mesh
-Particles for muzzle
-Takes control of events, and interacts with the player’s functions
-Holds specific animations for the player to do. Probably by simply overriding the default animations as governed by the animation code?
-Have a special position, cause a gun or a dagger are different shapes and are rotated and positioned differently

I’m assuming it would fit into a socket of the player…

I’m not sure how to have an object that connects the player via blueprint, and therefor overrides stuff on the player. I’m not asking how to do these individual things, I’m wondering what system to use that allows me to do these things. Would I simply make a weapon class and go on from there? But what would the weapon class be based on?

This system would be used for a lot of stuff, like armor and such.

Thanks!

Have a look at the ShooterGame example. it has a Weapon system that attaches to the player and replicates.

Ah, I didn’t know that the shooter game was in C++!! Thanks, mate! I’ll post my findings here for anyone else wanting to know what’s up. :wink:

Okay, so here’s what I found out and managed to get working:
-A weapon class. This is an actor class.
-Each weapon class holds a mesh
-A player holds an inventory array… full of weapons
-When you get a weapon out, the wanted weapon (which is already spawned in the world but is invisible) turns visible, becomes a child of the player, and then attaches to a socket
-Tada!

Quite simple, didn’t know that you could make children attach to sockets! :smiley: :smiley: