UE4 Damage Tutorial


page 1 2

1

1_1

This tutorial is based on 4.13. Epic changes the template projects slightly in updates to the engine, but this tutorial should remain applicable.

The tutorial is suitable for a single player game. Multiplayer is much more complex and you should know what you are getting into before starting that journey. For guidance on damage in multiplayer look at Epic's ShooterGame example.

Create a project using the first person template, and add the Animation Starter Pack marketplace asset.

2

2_1

First we need NPCs to be visible to the player. Open the FirstPersonCharacter blueprint (Content/Blueprints/FirstPersonCharacter) and select the 'Viewport' tab.

Select the FP_Gun component and change its rendering properties to "Only Owner See"

3

3_1

Select the Mesh component and change its mesh to SK_Mannequin. This option will only be available with the animation starter pack added.

Set its location and rotation to look right (Location 0, 0, -96.0. Rotation -90deg Z).

Set its rendering properties to "Owner no see."

Set its animation blueprint to "UE4ASP_HeroTPP_AnimBlueprint."

4

3_1

Add a Skeletal Mesh component to the FirstPersonCharacter blueprint named '3P_Gun'. Set its mesh to FP_Gun.

Drag and drop the new component onto the 'Mesh' component, parenting it. Attach it to the 'hand_r' socket.

Change its location/rotation to look right (Loc 0, 0, 0. Rot +90deg Z).

Set the rendering options to "Owner no see."

5

5_1

If you drag and drop a FirstPersonCharacter blueprint into the map it will become an AI (with no AI behavior at the moment).

Having done the above steps you should be able to see the AI character, but projectiles will pass right through it. Time to set up the collision.

6

6_1

In the main Editor window, go to Settings->Project Settings. Then open the collision tab.

Add a New Object Channel named 'Hitbox.'

7

7_1

In the FirstPersonCharacter blueprint, select the 'Mesh' component and go to its collision settings.

Set collision profile to 'Custom.' Then set Collision to enabled, the object type to Hitbox, and ignore all channels except Projectile, which should be set to 'Block.'

8

8_1

Open the FirstPersonProjectile blueprint. Select the CollisionComponent.

Check that collision is enabled (query and physics), and it is set to block the 'Hitbox' channel.

Now projectiles should bounce off the character mesh.

page 1 2