Maybe like this :
//otherscript.js
var health : int;
var Maxhealth : int = 100;
function Start (){
health = Maxhealth;
}
function Ouch (damage : int){
damage -= health;
}
//groundscript.js
var player : GameObject;
var FloorDamage : int = 40;
function OnTriggerEnter(other:Collider){
player.GetComponent(otherscript).Ouch (FloorDamage);
}
I use this kind of thing a lot.
↧