I have a 2D platformer with each platform having a
PlatformEffector2D component. I want to create a crate that can be pushed.
When I jump into the edge of the crate, my player gets stuck, so I added
PlatformEffector2D to the crate. But when the crate has a
PlatformEffector2D component it falls below the platform.
I can remove the component and add a
Physics2D Material with zero friction to prevent the player from getting stuck in the crate's edge, but I can't walk above the crate (because the zero friction). The images below illustrate it.
Player getting stuck in the edge of the crate that don't have
If it has a
PlatformEffector2D it will fall below the platform.
My objects have the following components (when the player gets stuck at the edge of a crate):
Player (BoxCollider2D, Rigidbody2D)
Crate (BoxCollider2D, Rigidbody2D)
Platform (EdgeCollider2D, PlatformEffector2D)
What should I do so my player can push the crate and walk above the crate? Would anyone happen to have a sample script?
FYI: I use Physics2D.OverlapCircle to detect the ground. (Unity 5.4.0)