[Unity] Can't find bug in code, that spawns bonus objects with no collision bodies
Hi there, I have a problem with my game. Here is a short showcase of the problem.
When 2 balls (fruits) with same level stick to eachother, they should dissapear and create new ball (fruit) with 1 level higher - or disapear completly if it was the max possible fruit level. Sometimes there is a bug, when at random - for me - moment game catch a little freeze and spawns 3+ balls with no collision body.
3 Replies
The script behind whole mekanism
Feels like multiple collision detections triggering merge logic simultaneously, idk much about game dev but i would suggest try preventing multiple merges first
Skimming through the code, looks like the ID check below can be passed twice per frame if there are three fruits colliding with each other at once (which can happen when a new ball gets created and immediately collides with two balls of its type):
Thus two fruits would be instantiated at once (and will 100% collide with each other immediately)
...would be my guess anyway, seems to somewhat track with the chain reaction seen in the video