Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am implementing a 2d mobile racing game. I have already implemented a 2d terrain using a physics engine (using edges). Now i would like to implement a looping very similar to the one in the old super sonic (http://higherorderfun.com/blog/wp-content/uploads/2012/05/Sonic_2_Loop.jpg). The problem is if i use a normal edge the car hits in the edge when going up the ramp (which is completely logical). Does any one have any experiences on how to make a looping using a 2d physics engine (without faking it)? Is it even possible (i know that is possible in 3d).

Thanks for the help!

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Implementing layers would work, does that count as "faking it"? For loops you can transition between layers at the top of the loop and at the 'output' end of the loop. The left part of the ramp is in a layer below the right part of the loop:

enter image description here

Red is the back layer, blue is the forward layer. I imagine you can set a zone at the transition point to send your cars back a layer when they pass through that zone. Likewise, at the exit you switch back to the forward layer. When an object is in the forward layer, it ignores collision objects in the back layer and vice versa. For this reason, you'll want to have overlap at the transition points, to ensure you don't have objects falling through the terrain.

Alternatively, you can create a collision object that cares about the angle of incoming objects.

enter image description here

Compare the object's heading with the normal of the collision edge. If they are perpendicular, proceed with normal collision response. If the angle between the normal of the collision edge and heading are off perpendicular by some amount (20 degrees? It'll take some testing), allow the object to pass through the collision edge.

These special edges would be at the left side of the loop and the bottom.

share|improve this answer
    
thank you very much, its nice and its clean! :) –  jernej Apr 6 '13 at 2:06
add comment

I don't do game development yet, but I read up on it out of curiosity and for the sake of learning. I recently read an article by Patrick Wyatt about overcoming path finding and collision difficulties in the development of Star Craft because they used the old Warcraft engine, which didn't support the isometric view for collision boxes. They did some pretty neat hacks that I think will help you out. Have a look here.

Hope it helps!

share|improve this answer
1  
it doesn't help since my game is purely 2d and i am looking for a clean solution without hard coding the path when you enter the loop (i will resort to this solution only if i can't find any better one). Thanks for the effort though! –  jernej Apr 5 '13 at 15:40
1  
Starcraft is a purely 2d game as well. I think the point of his suggestion is there may not be a way to easily implement this kind of behavior, and that you may need to implement a hack of some sort. –  UnderscoreZero Apr 5 '13 at 16:32
1  
As UnderscoreZero said, the engine is 2d, but the artwork gives it the illusion of being "3d". The principle is the same, but the execution is different in the artwork –  Deathnerd Apr 5 '13 at 19:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.