I’m new with Unreal Engine 4.6 and I want to create a FPS game for training.
I have a custom character class “HumanCharacter” and a custom projectile class “Projectile”.
My character has two variables “float Health” and “float AttackValue” and I want to do this “Health -= EnemyAttackValue;” anywhere (of course with functions, it’s just for example).
I tried with “void OnHit” function but doesn’t work (when my projectile “hit” my character, there is a collision with it but the function OnHit is not called).
So… Does anyone have a simple solution to a damage system between two characters who shot above? A solution with explanations would be welcome, and all this in C++ obviously.
Add a delegate to handle OnStop or OnBounce from the ProjectilleMovementComponent in your Projectile Actor. Get the Actor from the hit result if it exists. Do UGameplayStatics::ApplyDamage to the actor passing in AttackValue for BaseDamage. Inside TakeDamage on your character class you can subtract the incoming damage from Health.