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?
1) 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.
2) 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?
asked Oct 12 '11 at 01:00 PM
I would try having a trigger below the platform that turns off the platform's collision, and then when the player leaves the tigger area, turn the collision back on. The trigger should mostly cover the platform, with the exception of the very top.