This seemed a LOT easier in my head.
I’m building a 2.5D Side Scroller & I can’t figure out how to create a basic weapon system.
I need to:
A) Start with a Machinegun & fire projectiles (Infinite Ammo)
B) Attach new weapon to the Weapon Socket (I created it on the r_hand)
C) Walk over & Pick up a NEW Weapon (ie. Shotgun) & replace the old weapon (Infinite Ammo)
I already have a working Projectile that hits the enemy & destroys itself on impact reducing the enemy Health, but do I want the projectile firing from My Character like I have it now? Or do I want the projectile firing from the Equipped Weapon?
I’ve gathered mostly that it’s best to have a “Weapon Base BP” and have each Weapon BP as a Child BP from the Weapon Base BP, but again… having problems with the ground work.
I’ve found a few links & tutorials that kind of help, but they have “loose ends” so I can’t quite replicate them.
Loose ends meaning they either have Macros or Functions that aren’t explained, am I supposed to build the BP in the Character BP? The Level BP? The Construction BP? Do I use a “Pawn BP” for the weapons, or “Actor BP”?
I guess that these are the things that programmers know by default, but I have 0 programming background.
I know this is a tough one, but I’m sure someone out there knows how to do this & I guarantee there are a lot of people that will benefit from this!
Yes making base class for items is practically a must or else you won’t build common interface for all weapons, you need to figure which varables and functions/events your weapons need and implement them in base class, then make child class for each weapon with own data (default variables) and code around framework you did in base. You also seems to fell in typical newbie trap of think that theres speciallized BPs, when in reality BP is valid class same as C++ class (you actually extend classes made in C++) and there many classes in engine that you can extend, watch my tutorial about basics of classes it might help you out: UUqYfJeXqXHTzlZ2PeqPLi3A
As for which classes pick to extend, for Weapon definitly Actor as you making your own kind of Actor isn’t? ;] As for inventory system that depends, if you want items to be attached to player (and by player i mean real player not character that he controls) you can place Inventory code (most basic form of it is simple array containing item objects) in PlayerController if you want to attach it to character that player controls (inventory that clears or drops toghther with it) place it in you Player Pawn or Character classes, you can make you own base character class with inventory system, this wya all you characters will have inventory including AI
In UE3 (or older) there was invetory system build-in, but in UE4 it was removed as that inventory system was made for shooter games and UE4 tries to be universal forcing developer to design there own system. You can check out old system out in Uncodex, all items was based of Inventory class:
and there was InventoryMenager class which was attach to pawn and worked like item container
It might inspire you and it should be recreatable in UE4 as the framework structure didn’t really change much since first Unreal game
I’m glad to know that at least I’m on the right track with the parent weapon BP and all weapon BP’s after that will be children of that.
But again, I’m not a programmer and It’s difficult to do even the easiest things with BP’s.
As I said in my original post,
I need to:
A) Start with a Machinegun & fire projectiles (Infinite Ammo)
B) Attach new weapon to the Weapon Socket (I created it on the r_hand)
C) Walk over & Pick up a NEW Weapon (ie. Shotgun) & replace the old weapon (Infinite Ammo)
I already have a working Projectile that hits the enemy & destroys itself on impact reducing the enemy Health, but do I want the projectile firing from My Character like I have it now? Or do I want the projectile firing from the Equipped Weapon?
Anyway, I’m still in need of help for this situation.
I’ve gathered that I need a Parent BP (we’ll call it WeaponParentBP) and that will house the shared components of all weapons. Then I’ll need a BP for each weapon (ex: ShotgunBP, MachinegunBP etc.) that will have specific values like Damage, FireRate etc.
Where I’m lost: Do the Projectiles Fire from the Individual Weapon BP’s?
& I can’t seem to make my Character walk over the weapon on the ground & have it attach to MyCharacter.
Been almost 2 weeks with no solution.
I’m trying to figure this out as hard as I can, but it’s just not happening.
A) Start with a Machinegun & fire projectiles (Infinite Ammo)
B) Walk over & Pick up a NEW Weapon (ie. Shotgun) & replace the old weapon (Infinite Ammo)
C) Attach new weapon to the Weapon Socket (I created it on the r_hand)
Question - Do I Fire Projectiles out of MyCharacter? Or out of the individual Weapons?