Hello
i am making a game in unity 2d (using c#)
i have 2 objects Currency and Shop
u get gold buy clicking on currency (script in Currency) and when u click on an item on the shop (script in Shope)you lose 5 gold.
how can i tell Currency that my gold is decreased by 5?
sorry i know it stupid question
edit#1:
lets say i have this script on my currency:
void OnMouseDown ()
{
if (gameObject.name == "aaa") // when i click on a cube i get gold
gold = gold +1
}
and this for the shop
void OnMouseDown()
{
GameObject access = GameObject.Find("aaa");
Currency gg = access.GetComponent();
int GoldIHave = gg.gold;
if (gameObject.name=="bbb" && Cost<=GoldIHave) // when i press a circle i buy something
//buy it
}
ok now how i tell the currency script that i bought something and lose gold equal to the cost?
or gold = gold - 5
– Anxo