Hello All,
I have a game object in my game (MoneyPrefab) and tagged cash,
What Im trying to do is every-time I collect this gameobject to increment guiText by 100
I seen how to do it by using Count++; but that just increments it by 1
I really didnt think it would be this difficult to figure out but here I am.
I have 2 scripts:
CashDisplay (attached to GuiText)
function Update ()
{
var prefix = "Cash: ";
guiText.text = prefix + CashCollect.Count;
}
CashCollect (attached to my Player)
static var Count : int = 0;
var CollectSound : AudioClip;
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if(hit.gameObject.tag == "cash")
{
Destroy(hit.gameObject);
Count ++;
audio.PlayOneShot(CollectSound);
}
}
Later I want to create cash packs of different amounts that the player can collect but I’ll cross that bridge later for now Id be happy to see how to increment by 100 each time the object is collected.