- Home /
Jumping from a floor to another floor (2D)
Hello, I want my to 2D character to be able to jump from a floor to another, by passing throught it, and then walking on it. I joined an explanatory picture.
Can you tell me how to do it ? Thank you for your responses.
Please, provide more precise information on what you exactly need, because here you are facing (at least) two problems: making the character jump and passing through floors. Which is the one you don't know about?
Answer by DajBuzi · Jul 24, 2014 at 08:33 AM
Hello,
You need to modify the physics setting "on runtime" so if you go to the edit > physics/physics2d you'll see this little "table" on the bottom. This table shows you how objects will collide. You can edit those settings via scripts and you need to make sure to switch them back after. So for the example:
if(Player.rigidbody2D.velociy.y > 0)
Physics.IgnoreCollision(someLayer, someOtherLayer, true);
else
Physics.IgnoreCollision(someLayer, someOtherLayer, false);
Hope you get the idea.
Regards, M.Rogalski
Answer by Tehnique · Jul 24, 2014 at 08:34 AM
When the player is in the air and below the maximum jump point (the apex), disable collisions with the platforms layer. When the player starts going down again, enable collisions.
To detect the direction (up/down) the player is going while jumping, you could use Rigidbody2D.velocity.
Your answer
Follow this Question
Related Questions
the player is flying off the ramp (collider) 1 Answer
Character doesn't jump repeatedly 1 Answer
2d Beat Em Up Jump Functionality 0 Answers
Collision with renderer.enabled? 0 Answers