Hello im looking for some help on something, being calculating DPS so currently i can see my damage when i hit a humanoid, but im trying to make it so i can see how much is done every second(damage per second), im just looking for some help on how to go about it as i can see my current dmg but not how much damage is done in a second?.
Heres a cool website I used for my game that may be of use to you, DPS (Damage Per Second) Calculator - Weapon & Spell DPS calculation.
You dont have to fill in the elemental stuff thats for magic n stuff
Hey sorry i might have missed out saying that i was going to place it into a textlabel
That does not change anything really
You can’t calculate DPS just from the damage dealt per hit, you must multiply that by the number of hits per second.
private void hit(GameObject other)
{
Rigidbody targetRigidbody = other.GetComponent<Rigidbody>();
if (!targetRigidbody)
return;
targetRigidbody.AddExplosionForce(explosionForce, transform.position, explosionRadius);
EnemyHealth targetHealth = targetRigidbody.GetComponent<EnemyHealth>();
if (!targetHealth)
return;
float damage = CalculateDamage();
targetHealth.TakeDamage(damage);
}
So i have this code and i want to calculate the damage every second.
And i have this code
public void TakeDamage(float amount)
{
amount -= armor.GetValue();
amount = Mathf.Clamp(amount, 0f, amount);
currentHealth -= amount;
Debug.Log(transform.name + " takes " + amount + " damage");
healthBar.SetHealth(currentHealth);
if (currentHealth <= 0f && !isDead)
{
Die();
}
}
as my damage code for the humanoid, any help would be great.
You can use the Time.deltaTime
to calculate the damage per second.
float damagePerSecond = damage/Time.deltaTime;