Hi, I’m looking for a damage script for flames and things like this.
I need a script that damages every character in its range.
Put this on your flame:
var DPS = 5.0;
function OnTriggerStay (other) {
other.SendMessage ("ApplyDamage", DPS * Time.deltaTime, SendMessageOptions.DontRequireReceiver);
}
And then put this on anything you want to be damaged by the flame:
var HP = 50.0;
function ApplyDamage(damage) {
HP -= damage;
if (HP <0) Destroy(gameObject);
}
Obviously the HP <0 effect will need to be tailored to your game. Hope this gets you started.
Thank you careyagimon!
It’s working!
(I don’t need the health script, I’ll take the “damage receiver” code from FPS tutorial)