For my first unity project, I have built a side scroller/platformer using the unity 2D subset. I would like to introduce a looped track as in the picture below:
The noob question: Must I use 3D objects to implement this loop? Obviously the car and track have to have different Z positions when entering and exiting the loop. Since the 2D colliders seem to ignore Z position come to think of it, perhaps the loop itself can be 3D colliders. Can anyone suggest a simple way of handling this special case in my otherwise 2D game?
When you set a texture as Sprite you can define what layer to be at. You can for instance have the front track to be at layer 2 while the lower part of the loop is layer 1. This will then place the layer one behind layer two as displayed on your picture. The problem now will of course be the collision. But with help of some simple code you can for instance remove and add collision based on the current position of your cart.
The tricks is wheen a ignore collision is done; then you want back the physics
to works between the object, you have to deactivate the object and reactivate it
in the same frame; that reinitialise the collision…