|
Hello I need to understand how this is calculate,I have a DamageSystem.js for all type of damage, with inside and a send message on FPS Walker My questions is, I want remove 5 for fallDistance >= 15 + 20 for fallDistance >= 20, in total 25, but need write 4 and 19. Why will be removed 5 health point for if (fallDistance >= 15), and 20 for if (fallDistance >= 20), if I write 4 and 19 hope is understandable and do not did a mess
(comments are locked)
|
You first subtract the actual damgage from your health then you subtract additional 1. thanks a lot
Aug 11 '12 at 11:12 AM
Ingen
(comments are locked)
|
|
As @zyzyx said, you're actually applying Damage+1. You could make your code more clear by just subtracting Damage from HEALT, and improve the messaging by using a single SendMessageUpwards (SendMessage functions are a bit slow):
function FallDamage(Damage :float ){
HEALT -= Damage;
Debug.Log("I'm falling");
}
// send message:
...
function FallingDamageAlert (fallDistance : float) {
...
if (fallDistance >= 15){ // if fallDistance >= 15...
var damage: float = 5; // assume damage 5...
if (fallDistance >= 20){ // but if it's >= 20...
damage = 25; // change damage to 25
} // apply the specified damage
gameObject.SendMessageUpwards ("FallDamage", damage, SendMessageOptions.DontRequireReceiver);
Debug.Log ("Ouch! Fell " + fallDistance + " units!");
}
}
thank you very much Aldo, I tried to do this but without find the right way, I need too much learn thank you again
Aug 11 '12 at 11:38 AM
Ingen
(comments are locked)
|
