Blueprint Catch

Hey,
I want to catch an Event of my Character Blueprint in my Weapon Blueprint. But i dont find it…

I read this post: Lets Make: Weapon in Blueprint from Blank Project - Blueprint Visual Scripting - Unreal Engine Forums and want to create the same…

Please help me :slight_smile:

It’s a good starting point to watch some of the Blueprint tutorials on YouTube,
This is a video from Epic which shows how to interact with other pickups:

Once you got the basics down, a good idea is to look into Blueprint Interfaces which
is useful if you have more than one type of Weapon/Object that share the same functionality.
Read here to find out how to create and implement an Interface:
https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/index.html

Alright, once you understand the basics let’s get to the fun bit!

Here is an example of an Interface called IWeapon,
It has a function named OnPickup which has
2 output
parameters,
the output parameters are Weapon Type and Ammo.

Weapon Type is a String and holds the display name of the weapon (eg. Shotgun, Handgun, Bazooka),
and Ammo is the default amount of ammo you get when you pick up the weapon.

Interface:

http://imageupper.com/s03/1/7/U1398204337647708_1.png

To implement the interface into your Weapon Blueprint,
click on “Blueprint Props” and add the interface in the Details tab!

http://imageupper.com/s03/1/7/U1398204337647708_2.png

As soon as you’ve added the Interface you’ll notice that your blueprint got a new function called OnPickup
Modify the OnPickup function to output your desired Weapon Type and Ammo, like so:

http://imageupper.com/s03/1/7/U1398204337647708_4.png

The weapon blueprint will now output “Shotgun” and 10 Ammo once the function is called,
so how do we call the function?
You can call the function by checking for an overlap with the weapon, this is done in your Character Blueprint:

http://imageupper.com/s03/1/7/U1398204337647708_3.png

Great! every time you walk over the weapon it will destroy itself and print “Shotgun” “10 Ammo”.
That’s the basics of how to pickup a weapon.

– ADVANCED
But let’s not stop there! You might not want to automatically pickup a weapon when you walk over it,
perhaps you’d want to only pickup the weapon when you press the F key?

And what happens when there is more than One weapon to pickup? which weapon should you pick up first?

An easy solution is to use Priority, where the highest priority weapon gets picked up first.
For example, you might be standing over a Handgun, a Shotgun, and a Bazooka,
the player would usually want to pickup the “best” weapon so we give the Bazooka the highest priority.

That can easily be done using arrays.
Basically, each time you overlap a weapon add the weapon to an Array
and once you hit the “F” key pickup the highest **priority **weapon!

  1. Modify your Weapon Interface to include a **Get Priority **function, the output can be a **Float **or an **Integer **depending on what you want.

  2. In the Character blueprint, we check for a Begin Overlap event and add the weapon actor into an Array.
    When an Overlap has ended, we want to take that weapon out of the array so that we do not pick it up when we are too far away.
    Once the **F **key is pressed we loop through the actor Array and pickup the weapon with the Highest priority.

http://imageupper.com/s03/1/7/X1398211908642894_1.png

If you decide to use the blueprint as a starting point then do make sure that your weapon has a priority higher than -1 to successfully remove the it from the weapon index.

Hey first of all. Wow thanks!!! I didnt expect this kind of answer! Im totaly stuned.
:slight_smile: