Reply To: Character Falling Through Floor

Home Forums Books Mastering Unity 2D Game Development Character Falling Through Floor Reply To: Character Falling Through Floor

#9732

Ohhh, that was fun and did have my head scratching for a few minutes until the lightbulb moment.

So, one thing you have to remember is that ALL objects that have a rigidbody will be affected by physics motion like gravity.  Objects with a box collider will be affected by other objects with colliders impacting them, usually by stopping them in their tracks like a wall (unless the collider is a trigger, in which case it will just set off an alarm).

However if one object has both a box collider AND a rigidbody, impacts with another object with a collider and a rigidbody then physics will be applied by those two objects colliding.

Let that sink in and look at your scene.  Answer further down the page.

 

 

 

 

 

 

 

Your wizard is standing on your players head 😀 and has gravity applied.   Hence he pushes the player down.

I tried creating a new player and sprite, applying collision and the rigid body to it, with gravity it dropped, without it didn’t.  Rest the players gravity in case it was some weird new Unity bug and then spotted it.

 

I must say that was the most fun issue I’ve come across and it made me smile when I finally figured it out.  Much better than a typo in a script.

I wish you well on your Game Dev journey and if you have any other issues please do reach out.

 

Simon (Darkside) Jackson
@SimonDarksideJ