- Home /
2d collision detection
I am making a platform game and I can't for the life of me figure out how to make my player collide with the ground with unitys new 2d features. The player just falls right through the ground. My player and my ground both have rigid body's and my player has a character controller. The ground has a square collider. They are both sprites. Can anyone help me? Thanks
You have a Rigidbody2D on both objects? Both objects have Collider2D colliders? While I haven't tested it, a CharacterController likely uses Physics.Raycast() rather than Physics2D.Raycast() so will not sense objects with 2D colliders. It is best to stick to either all 2D or all 3D.
Is one of them set to be $$anonymous$$inematic. $$anonymous$$inematic rigidbodies don't interact with the physics engine. also as robertbu said the character controller is for 3D which won't interact with any of the 2D physics.
Seems stupid but make sure both your game objects Z coordinates are the same.
Ok Thanks. I'll try taking off the character controller and using rigid body movements ins$$anonymous$$d
@$$anonymous$$Ohhh - 2D collisions use Vector2s. The 'z' coordinate of object is ignored, so the object don't have to have the same 'z' values.
Your answer
Follow this Question
Related Questions
How to detect multiple Colliders in the same object? 2 Answers
2D Coins and Points 1 Answer
Colliders 2d apparently touch each other even if they should not. 2 Answers
Moving an object with a collider in 2d? 1 Answer
Do I really have to do this? 2 Answers