Page Info
Engine Version:

5. Destroying the Rock

Choose your OS:

In this step, we will allow our rock to be destroyed when it is hit by the projectile the player fires. To do this, we will use another Bind Event, but we are not going to bind it to an Event Dispatcher. Instead we will use a collision event called OnHit which fires off when the collision of our rock is hit by something which is perfect for our situation.

Let's blow stuff up!

  1. Back inside the FirstPersonCharacter Blueprint, find the Spawn Actor node where we spawn our rock.

  2. Drag off the Return Value of the Spawn Actor node and choose Assign On Actor Hit.


  3. Connect the Spawn Actor and Bind Event.

  4. Off the Return Value of the Spawn Actor, choose Apply Radius Damage (Destructible).


    We could use Apply Damage, but would have additional parameters to enter. For simplicity we are going to use Radius Damage.

  5. On the Apply Radius Damage node, enter in 50000 for each of the fields shown below and connect a Get Actor Location node.


    This will ensure we do enough damage to actually cause the rock to explode into pieces.

  6. Following the Apply Radius Damage node, add a Set Score node.

  7. Hold Control and drag in the Score variable and connect it to a Int + Int node (set to 1) and connect the nodes.


    This will get the current score and add 1 to it each time a rock is hit.

  8. Connect the Bind Event and Set Score nodes to a Delay node set to 3 seconds.


    After 3 seconds once the rock has been spawned (whether it was hit or not), we are going to destroy it.

  9. Following the Delay add a Destroy Actor node.


    Drag off the Return Value of the Spawn Actor node and feed it into the Target of the Destroy Actor node.

  10. Following the Destroy Actor node, add the Set IsActive variable node and leave it unchecked.


    We are now saying that the spawned rock is no longer active so the player can spawn another one (if they have enough pulls left).

Our core gameplay is set up, if we were to play in the editor now you would see that you can show spawn, shoot and destroy a rock which is spawned from a random spawn point in the level. In the Next Step, we will communicate with our HUD and update the values displayed based on the values from the Character Blueprint.