- Home /
Damage Meter
How could a damage meter be made like the Super Smash?
Answer by NonsenseSynapse · Apr 10, 2018 at 12:55 AM
Could you provide a bit more detail about what aspect of the Super Smash damage meter you need help with?
In a broad sense, you will want to assign each character a damage
variable that tracks how much damage they've taken, and then have a helper function that converts that damage into a damageFactor
which determines how much it will affect the character's knockback. For example, it could look something like this (note: I don't have Unity in front of me so consider this to be somewhat pseudocode):
private float damage;
// First, we calculate the damage factor based on the current damage. In this example,
// I divide by 10, but your actual calculation might be a lot more complicated. I would
// recommend assigning public variables to the different values in your function so
// you can easily test how it plays with different values.
private float getDamageFactor() {
return this.damage / 10;
}
// Here, we fetch the mass of the rigidbody and multiply it by the damageFactor. This is
// assuming that mass is what is used to distinguish a heavy character (like Bowser) from
// a lighter character (like Sheik)
private float getKnockback() {
rb = GetComponent<Rigidbody>();
float damageFactor = this.getDamageFactor();
return rb.mass * damageFactor;
}
You could then multiply the result of getKnockback()
by the normal velocity change of a hit in order to make a character go flying more or less depending on how much damage they have taken.
@NonsenseSynapse , yes, something like that was needing. thanks
how could I make it show on the screen?
Your answer
![](https://koobas.hobune.stream/wayback/20220612160421im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Health Regen Stop After Damage 1 Answer
Health Code, Damage and Healing 0 Answers
Health below zero but shows negative numbers 1 Answer
Help w/variables 0 Answers
Health Bar going 0 right away 1 Answer