- Home /
Polygon Collider 2D collision problem
I have a ground texture and I used polygon collider on it as you can see in the below picture.
The polygon collider perfectly fits with my texture and I have a ball which moving continuously to the x direction. The ground tiles itself infinetely. Sometimes (not all the time) when the ball goes very fast, the polygon collider acts like there is nothing there. The ball goes inside to the ground like the picture below.
The ball has a circle collider 2D with no triggers and rigidbody 2D with default values. The ground has polygon collider 2D with no triggers and rigidbody 2D isKinematic=true;
I can also reproduce this bug when the ground's rigidbody isKinematic=false;
Can somebody help about this issue ? Is this a bug about polygon colliders ? Or, am I doing something wrong ?
Some times the collision is not triggered because the GameObject is to fast.
Here the explanation. objectA is at 0,0 and the wall is at 1,1. If the objectA is going slowly, the engine will have the time to detect the collision and prevents it to go through the wall.
But, if your object is too fast, the time between the 2 calculation will let the object go through. The last time I've had this problem, we solve it by reducing the speed of the objectA.
For your second solution, i've had the same problem yesterday. It doesn't detect the collision. I think it's bescause the second object use the force system to don't let the first one go through it.
Did you find any solution? I think polygon collider 2d is not perfect. Use the box collider 2d.
Answer by theleonn · Dec 14, 2016 at 06:39 AM
I solved this problem by changing the Collision Detection in RigidBody2D to Continuous.
Of course this will make the code more expensive, because the Collision Detection will be always calculated even when not in use.
Answer by shieldgenerator7 · Mar 28, 2018 at 09:10 PM
Remove the RigidBody2D of the ground. Static objects don't move and thus don't need a RigidBody2D. RigidBody2Ds are only for objects that are meant to move. Removing the ground's RigidBody2D will make the game run more efficiently, too.
Answer by RabidCabbage · Mar 09, 2015 at 11:40 AM
Have you tried increasing the Iteration solver count in Edit > Project Settings > Physics/Physics 2D ?
I don't know what does "iteration solver count" do but i tried. The default value was 6 and I increased it to 60 but the bug is still there.
Your answer
Follow this Question
Related Questions
rigidbody 2d goes through polygon collider 2D 0 Answers
How can I detect collision with a text mesh without manually creating a polygon collider? 3 Answers
3d ground for 2d gameplay / side scroller 1 Answer
Distance-based collision detection not accurate 1 Answer
Detect Collisions with Object following Mouse Movement 2 Answers