About Simple Weapon System

Hello everyone. Right now i’m working on a weapon system. I got stuck on it. What i want to do is check if has already the same type of weapon. if it is, then don’t take it or ask for swap them with a widget. I create one master actor bp and the weapons are child of this one. Also created some enums and structures for it. Any answer will be helpfull. Thanks…
Also the pickup system is working correctly. It takes weapons by types to correct sockets.

These are my BPs;

I’m not sure I understand what you want. You just want a way to check which kind of weapon your player already has ?

If you want to check if your character has the same type of weapon, I suppose your character class holds a reference to the currently equipped weapons.

It depends on the way you are picking up your weapons I guess. If you are on a “Walk on the weapon to pick it up” type of behaviour, you should just use the OnActorBeginOverlap of your weapon. You check if the actor that overlapped is your character, compare his weapons’s type with the type of the weapon that was overlapped and it should work.

If you are using a “Skyrim” type of pickup, like ray tracing from the center of your screen and then pushing a button to pick up what you see, I guess you have to create an event on your weapon that takes a Character reference as input. So the character can send a self reference to the weapon with this event, so that the targeted weapon can access the character’s weapon reference to compare its type with it.

Was it clear ? Or are you using a different pickup mechanic ?

I don’t know. It looks like you don’t have any data storing an inventory of what weapons are picked up by the player, you just attach the weapons to their character.

So maybe you could Get All Socket names (there’s a node with a name like that sort of), and loop through the sockets, and maybe there is a way to see what is attached to each socket? I don’t know if there is. Just guessing some ideas since I don’t have Unreal open in front of me right now.

Yes this is exactly what i want actually. If the character has the same kind of weapon then don’t take it or ask for swap with the new one. That’s it.

Also i edit the post. Sorry for bad English.

Thanks for your answer. It’s light up a lamp on my head. I should have add my event graph also. I add a sphere as component to master weapon bp. When character overlaps, a variable sets to true like CanPickUp? Then when i pressed F key, It checks that is character on sphere and the weapon type as you can see on my first post.

So if i understand correctly, i need to check this sphere is overlap to character. and i can do that with OnActorBeginOverlap, right? It seem’s reasonable. But on the other hand the other mechanic you have talked about seems like better than mine. But it’s like more complex. Should i used that on my project for quality?

And my pickup mechanic ofc.

Well this is a good suggestion. Thanks. I don’t want any inventory system in my project but maybe for this one i should. I’m new to ue4 so i want to create this in a simple way. I just watched a enumaration tutorial about something and then i said why i can not use it for the weapon types :slight_smile: I’ll give this node a try anyway if i can correctly connect the nodes :slight_smile:

I don’t really understand what you are doing with your “disable input” here. You are checking the character on overlap, that’s good, then take this character and check what type of weapon he already has (of course when you pick up a weapon you have to store it in a variable in the character, you didn’t show your character blueprint). If it’s a different type from the overlapped weapon, pick it up, otherwise, do what you want.

About your input, it should be handled in the character or the character controller, not the weapon I think.

And about the type of mechanic you use, just go for what you think is the best for your game. The raycasting one may be a little bit harder, but the other one also has difficulties (imagine if you overlap multiple weapons) and it can be great too (It worked in Dark Souls after all! ) just implement your favorite =)

I was thinking that would be good if i put the input key to weapon bp for reaching easily hahah :slight_smile: I used a tracer for calculate the object width/height to check that the character should vault on it or climb on it. That worked perfectly so there is no reason to change the weapon system to it for me. In order to overlapped weapons i think i am going to change the mechanic to the raycasting. :slight_smile: And also i think i should create a variable like an inventory system in my character bp to storage what kind of weapon types does he have. I dont have to use for it to show inventory anyway :slight_smile:

So thanks for your help, it was realy helpful for me. I’ll add the process here so if anyone wants to do something like that they can get inspire from it :slight_smile: Also i don’t think that i will make this work without any other problems hahah

Cheers!

Good luck, I remember there was a good tutorial on youtube about an inventory system where it also showed how to pick up items with raycast. I can’t remember the name though, ad it was probably in C++, but the technique stays the same ^^

And don’t forget to mark your post as answered in case anyone is searching for the same thing, so they know a solution was found :wink:

Good luck to you.