Player Has 2D Circle Collider For Bottom, 2D Box Collider For Top And Has RigidBody2D, NO Kinetic.
Coin Is Just A 2D Box Collider Trigger.
This Happens Randomly But Usually With Coin 1 of 4 Or Coin 2 Of 4, Every Other Collected Coin, I’m Just Looping The Scene, So Next Scene It Might Not Happen But Next Scene It Will.
The Coins Are All Made From 1 Prefab.
I’ve Read Up All Day On OnTriggerEnter2D And No Ones Answers Fixed My Problem, If You Search “OnTriggerEnter2D Twice”, Or “OnTriggerEnter2D More Than Once” I’ve Read Every Search Result, And None Of Them Have Worked. I’ve Seen Other People With The Same Problem Or An Alike And Their Questions Haven’t Even Been Replied To Months Later.
Now It’s Saying I Can’t Add OnTriggerEnter2D As A TAG???
2nd Edit I Disabled The 2D Box Collider, And Tested, It Still Randomly Adds 2 Coins With Just 2D Circle Collider And Rigid Body Contacting 2D Box Collider.
The Destroy method will not remove your object immediately. Simply declare a boolean value and set it to true to ignore further calls until the object is destroyed.
Not sure if I can help, but here’s a few thoughts from my small experience thus far.
I see you’re adding 0.01f to a float which (i think) is tracking the amount of coins collected. Could it be that the starting amount of this float is slightly being modified somewhere, so that the actual value of the float is something (example) like: 0.146 (note the extra “6” at the end) In my projects, I’ve notes that sometimes, the values I’ve put here and there actually screw up the math, and add a little more or less. (Not saying you’ve screwed up. Just telling what I’ve done before, and what to watch for, especially since this is randomly coming up.)
Hmmm… what I usually have to do in situations like this is to add a variable to check whether I just picked up the coin (already.) Albeit, usually it’s a unique item, so I check to make sure (when this method (void OnTriggerEnter2D(Collider2D col)) runs, then I put a line or two to make sure that it doesn’t run 16 times while the rigidbody collides with the collider, and give me 16 of the object. So, it’s just a simple check to see if this object has already been picked up or not, and if not, then to pick it up/destroy… Not sure if this is really applicable here, since your code already has a destroy portion in it.
Perhaps you might first disable/deactivate the object before destroying it?