Announcement

Collapse
No announcement yet.

Blueprint Catch

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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: https://forums.unrealengine.com/show...ll=1#post20422 and want to create the same...

    Please help me

    #2
    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...ace/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:



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


    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:


    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:


    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.



    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.
    Last edited by User1189264810; 04-22-2014, 08:14 PM.

    Comment


      #3
      Hey first of all. Wow thanks!!! I didnt expect this kind of answer! Im totaly stuned.
      Attached Files

      Comment

      Working...
      X