- Home /
Best method to make the main character traverse multiple layers of objects using Unity 2D
I'm a mobile gaming student, I have a question regarding traversing multiple layers and disabling colliders. My game scene has 3 tiers of objects, and the goal is to have the character be able to traverse them by either jumping on them or swiping down to drop. The bottom tier is in the foreground, all the way to the top tier being in the background. I've been trying to find the most effective solution to disable/ignore collisions between the main player and objects not in the current tier.
As I have it set up right now, I have 3 invisible triggers spanning horizontally across the screen, and a small trigger underneath the character. When these triggers interact, the main player's sorting order changes to whichever trigger was last activated. Then I have the player ignore any collisions that are outside of his sorting order. This works fine about 70% of the time, but I'm running into an issue of him falling too quickly for the triggers to activate--also he'll randomly fall through some objects even if he's been running on them for a while.
I'm not looking for code, but instead looking for advice on the proper logic to implement layer traversal, and which Unity systems I should use. I've been stuck researching the best way to implement it--including using a horizontal raycast to switch a bool on the objects, then ignore collisions based on that, but I can't figure out an elegant method to then switch that bool back. Any help would be TREMENDOUSLY appreciated, as I've been stuck on this particular issue for almost a month. THank you so much
David
Quick idea here:
How about only enabling collisions when the character's Y component or height is higher than the other objects?
Okay, I'll look into doing it that way. THanks for the suggestion
Answer by RemDust · May 25, 2016 at 02:13 PM
Why not using the 2D platform effectors ? I think this could be exactly what you're looking for, check it out. :)