Skip to content

Multiplayer Series UE4 [3] – Character

Damage Dealing

For Projectile we need to create new Collision Channel, so go to Project Settings -> Engine -> Collision.

Click New Object Channel and add Channel Projectile.

Use these settings for all Projectile related stuff.

In Character you need to create Collision boxes and attach them to Characters skeleton. This way we can identify hit locations.

  • TorsoCollision is Capsule Collision.
  • HeadCollision is Sphere Collision.
  • Rest are Box Collisions.

First attach them in Construction Script with AttachComponenetToComponent.

And then resize and move them.

Remember to set their collision settings too.

Create RegisterDamage function in Character. This will calculate and updates DamagePoints in Player State.

Click for bigger

Create On Componenet Begin Overlap events for all damage dealing collision boxes.

Now we simply do something like this.

First we need to use Switch has Authority so this only happens in server.

Then we filter out all other hit’s with Cast to Projectile.

Then we input Velocity, Mass and Strength Multiplier into RegisterDamage. Velocity should actually come from Projectile but we will get that right soon.

We also need to call PawnBegin from Player State, there’s a small delay before PlayerState variable is set at the beginning so we need to use delayed loop.

Now damage dealing should be functional. You can create simple test projectile before moving on with this tutorial.

Pages: 1 2 3 4 5 6 7 8 9 10 11
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
Level Paradox
0
Would love your thoughts, please comment.x
()
x