Download

Identify equipped weapon

Hey

Does anyone know how I can do a check against the weapon the player has equipped to see if it’s the correct one I want? Or alternatively, is there some way to map a key the fire button to do something else on only one of the weapons that the player is carrying?

Thanks

This depends on how you go about equipping the object. If you are attaching it via socket, I suggest that you store a reference to your weapon when attaching it, so that you can just compare the reference.

Im afraid I don’t follow exactly. How I store a reference or later compare it with what or where to place them all. Im using the launcher from the ShooterGame and the FPP hero character as well and Im gonna modify the Launcher to be a remote switch instead.

Create a Variable of type Actor Reference in your Player Controller blueprint. Name it “CurrentWeapon” or something like that.
When the Player Controller receives the “equip weapon X” event, it puts the right weapon actor into the right socket, but also puts a reference to the weapon actor into that variable.

What you need to look into is casting. Give all your weapons the same base class for common functionality and then cast to the specific weapon if it has specific functionality.
If you don’t need common functionality then skip the first part, but essentially when a cast fails then you know that that variable doesn’t represent the weapon you tested for.
Or on the other hand if it succeeds then you know the player has the weapon you need.