I’m pretty new to the getcomponent function in java and I want to learn it,I did not understand the unity docs, so here I am, How do I make an getcomnponent to my player and a script called moneysystem and access the int called money in the system?
i got my code to give me money here
#pragma strict
var Health = 100;
var tombstone : GameObject;
thePlayer : GameObject;
function ApplyDammage (TheDammage : int)
{
Health -= TheDammage;
if(Health <= 0)
{
Dead();
}
}
function Dead()
{
Instantiate (tombstone, gameObject.transform.position, Quaternion.identity);
/*GET COMPONENT HERE
--------------*/
Destroy (gameObject);
}
and here’s my money code
var money : int = 1000;//amout of your money
function Update()
{
if(money < 0)
{
money = 0;
}
}