- Home /
2d Collision not detect player when it falls
Hi i working on a 2d game, i have tiles and object with collisions and everything is fine. but sometimes when my character falls from a great height, collision doesn't recognize it and it passes through them. is it a bug ? ( player has rigitbody2d and tiles has static rigitbody2d )
Answer by VincentR · Apr 23, 2020 at 06:56 PM
Well it's a common issue. What seems to be happenning is that your collider is too small and your character is going too fast. Think of your character moving step by step, even if those steps are little. If your collider size is smaller than the step, your character will virtually "jump over" the collider. Try increasing the size of your collider or limiting the speed of your character (or both)
You could also tweak the values in ProjectSettings/Physics(2D), such as Velocity Iterations. Be aware that it could affect the performances though.
Thank you for your help i checked compose collider 2d and found geometry type is outlines and that causes problems changed to polygons and problem is solved
Answer by Triggerly · Apr 23, 2020 at 03:06 PM
Tag your player with the tag 'Player' and then add code like this:
// Put this script on your collider that detects when the player falls.
void OnCollisionEnter2D(Collision2D coll)
{
// If the object is called Player
if (other.name == "player")
{
// Do stuff here
}
}
thanks for reply, buy i don't think what you said has anything to do with my problem