So, I’m creating a sidescroller, and I’m having trouble achieving a certain gameplay effect. Basically, I’d like for my character, with a rigidbody collider, to be able to jump to platforms by jumping up through the bottom of them – a la Sonic the Hedgehog. In the script I’m using that detects collisions between the player and the platforms, I’m using Physics.IgnoreCollision to achieve this effect. The second time the player hits a platform he’s allowed to pass through it. But the first time my player character collides with a platform, he’s knocked back, and then he falls back through it. Is there a simple way of remedying this situation? I can see two potential solutions. Which one do you think is the winner?
-
I use colliders the same size as the platforms BELOW and ABOVE those platforms to turn physics.IgnoreCollision on and off when my player character hits them.
-
I turn Physics. IgnoreCollision off for all platforms until I am above them–then checking constantly to see which platforms are below me, and making sure those are on.
What do you think?