- Home /
OnTriggerEnter2D firing without an actual collision occuring
Hello,
I am working on a endless runner/fighting game hybrid where the player character must collect objects to score points. In its current state the collectibles are depicted using Dragon Balls from Dragon Ball Z.
Anyway, The player character has a child called HurtBox, which has a script that contains OnCollisionEnter2D to collect coins when the HurtBox touches them.
However, OnCollisionEnter2D is happening when HurtBox is nowhere near the Collider2D of the Dragon Ball.
Note: the big rectangle around the jumping character is the HurtBox, and the small circle in the Dragon Ball is it's Collider2D
What happens in the event of a collision perfectly fine, as you saw the Player's score rose to 1. I commented out the line of code that destroys the Dragon Ball and set TimeScale to 0 in order to see the frame the collision happens in.
For reference:
HurtBox has a RigidBody2D(Dynamic) & a BoxCollider2D(Is trigger).
Dragon Ball has a RigidBody2D(Kinematic) & a CircleCollider2D(Is Trigger)
My question is why is this happening, and what can I do to fix it?
Any help would be greatly appreciated. I can give more information on the Scene if necessary.
Your answer
Follow this Question
Related Questions
Bullets go through collider even with continuous collision detection! 0 Answers
After Collision Matrix change in runtime, effects not immediatly visible 1 Answer
My OnCollisionEnter says i have 128 Collisions every collision 1 Answer
Collision detection problem 0 Answers
Tile collision by sprite is not accurate with Tilemap Collider 0 Answers