Y
Y
yungprogrammerlowskill2022-01-03 08:23:14
Unity
yungprogrammerlowskill, 2022-01-03 08:23:14

How to make an account?

I have objects that are assigned certain numbers, when a player collects them, the sum of the numbers on these objects is recorded in the score, how to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
greedile, 2022-01-03
@greedile

Throw this script on objects with a coin:

public int CoinValue = 1; // Какое значение в себе содержит эта монетка?
private void OnMouseDown(){  
     MoneyEvent.MoneyAmount += CoinValue;
     Destroy(gameObject);
}

Code for Event, throw it on any empty object
public class MoneyEvent : MonoBehaviour{
 public Text txt;
 public static int MoneyAmount = 0;

 void FixedUpdate(){
        txt.text = MoneyAmount.ToString();
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question