damage script

in my game there is fire spread out throughout the map. I cant find out how to make a script that causes little repeating damage to the players health when he steps on the fire.

Put a box collider on the fire, set it to IsTrigger and child it to the fire. The add that script to the box:

function OnTriggerStay(other:Collider)

This is considering that your player health is a static variable (which is fine in this case) in a PlayerScript.js

Change as you need.

Be careful that this is called every frame, so you might want to temper the damage with some kind of timed damage. In this case, you would have to think slightly differently.

private isIn:boolean;
vat timing:int;

function Start(){
   isIn = false;

function Update(){   
       timing = Time.time;
           healthbar.health-= damage;

function OnTriggerEnter(other:Collider){
   if(other.gameObject.tag == "Player") 
      isIn =true;
function OnTriggerExit(other:Collider){
   if(other.gameObject.tag == "Player")
      isIn =false;