- Home /
Graceful 2D collision enabling/disabling for topdown jumping
I've been trying to implement a very simple 2D top-down jumping mechanic, similar to the top down zelda games. I've implemented objects that can be jumped over, by turning off collisions for specific layers when the Jump
event starts: Physics2D.IgnoreLayerCollision(PlayerLayer, ObjectsLayer, True)
The problem I'm having is that when I re-enable the layer collision, collision events don't fire until the PlayerObject moves. Which means that the player will safely land in a spike pit, but get hurt when they try to move out of it.
Is there any way I can force it to poll for collisions at a certain point? Or would it be better to handle collisions differently, seperate from the Unity physics engine?
I'm not very familliar with Unity, so I'd appriciate any help at all.
Answer by Greek_Soldier · Mar 14, 2015 at 03:44 PM
You could probably use an IEnumerator and change the player to a different sorting layer, yield for the amount of seconds the player would be above the ground for, and then change the player back. I haven't tested it yet but in theory it should work.
Your answer
Follow this Question
Related Questions
Generating 2D collisions for maze 0 Answers
Rigidbody2D characters push each other 0 Answers
How to fix, that every clone changes color, if I shoot at only one clone? 0 Answers
Unity 2D Top Down Jump 1 Answer
Collision counter 2 Answers