how do you really do damage?
Community Forums/General Help/how do you really do damage?
| ||
all i want is to make my player damage the enemy.. so this is just an algorithm.. if player attack the enemy enemy.health +=1 but whenever i do the detecting using entitydistance, or if entitycolided.. i always get big values. enemy.health=100 after attacking once enemy.health = 70 please help.. |
| ||
You're doing damage every single frame that the weapon is within range of the enemy. As soon as the weapon does damage, you need to stop it from doing any more damage. Keep checking the distance and as soon as it is too far away again, allow it to do damage once more. Or adjust your damage values to account for the damage happening every frame. But the former is probably what you want. |
| ||
Learn about what is and how to use a states system. You want your entity to only be damaged once by a hit of a weapon/projectile, else it will die too quickly ! |
| ||
Bring in "WeaponSpeed" and attack in this interval then. assume you have 60 logic ticks per second assume you have a weaponSpeed of 0.5 (means 0.5 times a second -> every two seconds) store "lastAttackTime" next to your unit/weapon deltaTime = (time since last Tick) / (time per tick) on logic tick: if lastAttackTime + weaponSpeed*deltaTime < currentTime Attack() endif Attack() does the damage and sets "lastAttackTime = currentTime" bye Ron |
| ||
another way is to use random E.G. if (me hit enemy) and rand(100)<50 then do damage varying the 50 to lower would lessen the chance to do damage |
| ||
Plus enemy.health +=1 is a heal |