Unity 2D collect and counting but counting system is not right,Unity 2D collect obj and count it but there's problem about counting
so I try to make part of the game that has a scene where the player has to collect 5 papers and then it's gonna be a condition to another step. I use code from this video (https://www.youtube.com/watch?v=D0lx90n0s-4&t=626s&ab_channel=JimmyVegas) and when I test it. it counts normally when it's not separate like this
and then when I separate all 5 to all around the map. it's going wrong. some of it doesn't count on the score. and this is the code i use for count paper
PaperScore.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PaperScore : MonoBehaviour
{
public GameObject PaperText;
public static int thescore;
void Update()
{
PaperText.GetComponent<Text>().text = "Paper:" + thescore / 2;
}
}
CollectPaper.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollectPaper : MonoBehaviour
{
void OnTriggerEnter2D(Collider2D collision)
{
PaperScore.thescore += 1;
Destroy(gameObject);
}
}
thank you for your help
Your answer
Follow this Question
Related Questions
How to get the Collider other element Rigidbody? 0 Answers
Change Scene with Physics Raycasting 1 Answer
Player Can Not get off platform 1 Answer
Problem in Destroy GameObject on OnTriggerEnter2D 0 Answers
touch to activate animation 0 Answers