Hello everyone,
I am new in Unity and I need your help. I am doing game almost same as on Image but I have got there 4 pick up objects with different shapes.
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("Triangel"))
{
Destroy(other.gameObject);
clipAudio.Play();
count = count + 1;
}
}
But when I picked up different object score has restarted.
Here is my ScoreController which doesnt work.
I have no idea what to do next. Please help me I will appreciate it.
public Text countText;
public int count;
public int Count1;
public int Count2;
public int Count3;
public int Count4;
private void Start()
{
Count1= GameObject.Find("Triangels").GetComponent<TriangelsPickUp>().count1;
Count2 = GameObject.Find("Squares").GetComponent<SquaresPickUp>().count2;
Count3 = GameObject.Find("Circles").GetComponent<CirclesPickUp>().count3;
Count4 = GameObject.Find("Diamonts").GetComponent<DiamontsPickUp>().count4;
SetCountText();
count = 0;
}
private void Update()
{
count = Count1+Count2+Count3+Count4;
SetCountText();
}
void SetCountText()
{
countText.text = "Score: " + count.ToString();
}