3. Adjusting Actor Physics & Collision

Here we will adjust the Physics Simulation for our Actor as well as the Collision properties inside the Details panel. By adjusting these settings we can define how an Actor responds to other Actors in the game world. We can set our Actor to simulate physics which will allow us to bump into and push the Actor around in the world as well as define how it responds to collision with other Actors.

Steps

  1. With the Shape_Sphere selected, in the Details panel under Collision, check the Simulation Generates Hit Events checkbox.

    Details18a.png

    With this option checked, we can determine if the sphere hits something.

  2. Also in the Collision section, click the Collision Presets drop down and select Physics Actor.

    Details18b.png

    Since we are going to simulate physics, this setting will handle the physics responses for us.

  3. In the Physics section, check the Simulate Physics checkbox.

    Details18c.png

    There are additional options you can set here such as the Damping or Contraints which can affect how physics for the Actor are simulated however for this tutorial all we are going to do is simulate physics so it can be affected by physics during gameplay.

    If you play in the editor now, you will see the sphere roll down the stairs and you can walk into it and push it around since it is a Physics Actor. In order to test the Hit Events, we will use a little bit of Blueprints Visual Scripting to kill the player when hit by the sphere.

  4. With the sphere selected in the level, on the Main Toolbar click the Blueprints button then select Open Level Blueprint.

    Details19.png

  5. Right-click in the graph window, then under Add Event for Shape Sphere and Collision, select the Add On Actor Hit event.

    Details20.png

    This will now fire an event when the sphere hits something.

  6. Off the OnActorHit node, drag off the Other Actor pin and search for Cast To ThirdPersonCharacter then select it in the window.

    Details21.png

    Here we are checking to see if the Other Actor we hit is the ThirdPersonCharacter (or Player used with this template).

  7. Drag off the As Third Person Character pin of the Cast node and search for and add the Destroy Actor node.

    Details22.png

    If ThirdPersonCharacter was the Other Actor hit, then destroy ThirdPersonCharacter (killing the player character).

  8. Click the Compile button in the upper-left corner of the window to finalize the Blueprint, then close the window.

    Details23.png

  9. From the Main Toolbar, click the Play button to play in the editor.

    Details24.png

End Result

When you play in the Editor now, you can use WASD to move the character around and the Mouse to manipulate the camera. You should see that the sphere now rolls down the stairs and if you walk into it, it should kill the character making them disappear (press Esc to exit the play session after you have been "killed").

This should give you a brief understanding of how to edit the properites of Actors through the Details panel of the main Level Editor. For more information, please see the related topics below.