Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit) (+1)

It’s been a while since I worked with Unity, but if I’m not wrong, when you call the Destroy() function on an object, this happens asynchronously. As in, it could happen on this frame, or the next one, or in 10 frames, which is why the score is incremented multiple times.

I would suggest to disable the collider on that object, before destroying it, so it will stop triggering collision callbacks until it’s destroyed.

I can’t remember the exact syntax, but inside “OnTriggerEnter” it should be something like that:

other.enabled = false;

This will ensure that object is not triggering more collision events on the same frame, while Unity will destroy it as soon as possible.

OK THANKS A LOT FOR HELPING

I WILL TRY THE THING YOU TOLD ME

:D