Just getting in to damage. I have tried YouTube for a simple to follow, how to apply damage to player if it is hit by a projectile. Not much luck without following a 1 hour TUT
I can work out, that upon projectile hitting player, you remove X from health. Just not sure how to do it effectively.
Does anyone know where one is. I would not mind knowing radial damage as well, but that is optional.
I created a attribute called damage on my Projectile and then when I apply damage to the player I subtract the amount of the damage attribute for the projectile from the health attribute of the players.
Not in front of my Dev PC or I could show you my blueprints.
Have you been able to detect when the projectile hits the player? For applying damage the following nodes will in handy: ApplyDamage and Event Any Damage.
In your project class, after hit something and detected that it was a character, call the function ApplyDamage (or ApplyPointDamage, ApplyRadialDamage) on the character.
Give the character a health variable and initial value > 0. In your character class, in your main event graph add an Event Any Damage node. This event is triggered on any damage including when ApplyDamage is called on this character. Use the incoming damage value to decrease the health variable like qdelpeche said.
Note that what should happen when a character dies (i.e. what dying means) is up to you to implement.
Should it be destroyed? Call DestroyActor.
Should it go ragdoll mode? Call SetSimulatePhysics on your character Mesh.
Should it respawn? Spawn a new character and let your controller Possess the new one.
I only saw your response now … I will need to check my blueprint from my projectile … but it was based on the normal FPS Template projectile … so you might need to look there first. If you don’t come right, I will send you the stuff when I get home from work.
Mate if I were you I would try to grasp how casting works, blueprint communication, look it up on YouTube.
Once you’ve mastered that I can assure you that you will be able to solve many of these little problems easily.