So i have a “health” script and I’m not sure if it’s made in a weird way or not, but that isn’t the question.
I want to make it so if the player comes into contact with another object it loses a certain amount of health (kind of like a Super Mario turtle in a way) my “health” script looks like this.
var player : GameObject;
var health = 1000;
function Start()
{
}
function Update()
{
if(health <= 0)
{
Debug.log("you are dead");
Destroy(player);
}
if(health >= 1000)
{
health = 1000;
}
}
How would you recommend creating the other script on another object that can find the health script on the player and subtract health?
thank you