4. Building the Grab Events

In this step you will be overriding the Grab Events on our GrenadeGunPistol so we can check to see if we want the gun to explode or not when it collides with things.

Steps

  1. Right-click in the Event Graph and search for Begin Primary Grab. Select Event Begin Primary Grab to add the node to the Event GRaph.

    image alt text

  2. Repeat this process for:

    • Event Begin Secondary Grab

    • Event End Primary Grab

    • Event End Secondary Grab

  3. For each of these Event nodes, you need to make a call to the same Event in the parent Blueprint to make sure that any existing functionality is still executed. To do this, Right-click the four event nodes you just created and select Add call to parent function.

    image alt text

  4. Connect the Event Nodes to their Parent Nodes.

    image alt text

  5. Click the + button next to Variables in the My Blueprint panel to create a new variable and name it bCanExplode.

    image alt text image alt text

    If you haven't created a new variable in this session in Unreal Editor, it will automatically be a Bool (the red icon indicates that it is a Bool). However, if you need to change it, select the variable in the My Blueprint tab and then you can change it in the Details panel:

    image alt text

  6. Click + Drag the bCanExplode variable into the Event Graph, and select the Set option.

    image alt text

  7. Duplicate the Set Can Explode node using Ctrl + W and click the checkbox in the new node to set the value of bCanExplode to True.

    image alt text

  8. Finally, connect the Parent nodes to the corresponding Set Can Explode nodes as shown below.

    Copy Node Graph

    image alt text

    Click the icon in the upper left corner of this image to copy the Blueprint Graph and paste it into your project.

  9. In the Blueprint Editor toolbar, click Compile to update the Blueprint and click Save to preserve your changes.

Results

These sets of Events are called when our gun is grabbed and released. You'll use the bCanExplode variable in the next section of the Blueprint to prevent the gun from exploding in your hand when you punch a robot with it.