- Home /
Collision Counter +1 To Counter Only Once When Collided
Hello, I have a counter in my game. Every time my Player collides with one of the 47 game objects l want my counter to have another count added to it. I can do this, however what l can't do is make it only happen once. For example, When my Player collides with GameObject1, this adds 1 to the counter and when he collides with GameObject2, this adds one to the counter, but when he then collides with GameObject1 for a second time the counter does not move, the score does not go up one. I would appreciate the help if someone could show me, thank you. - Cameron
Answer by allenallenallen · Aug 21, 2015 at 09:17 PM
You can put the collided game objects into a list. When the player collides with one of the 47 objects, loop through the list to see if it is in the list already. If it is, don't add to the counter. If not, add to the counter and add that game object to the list.
Your answer
![](https://koobas.hobune.stream/wayback/20220612000902im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Coin Counter still not working after 5+ hours of frustrating changing code and moving stuff around 2 Answers
how to keep track of bricks broken 1 Answer
How to stop object from going through walls. 4 Answers
Create A Counter And GameObjects Unique ID 1 Answer
Detect cloned object detection once 0 Answers