For those of you who have followed my OTHER 3 physics based gravity engines, this will come as no shock; Version 4! This is NOT the same as the other engines, and actually works on extremely different principles, but gets the same results, much simpler so.
This is a full platforming engine for TGF that will simulate gravity in the pseudo-physics way that Super Mario Galaxy does! Unlike my other engines, which focused on calculating the effects of point-gravity sources upon the player, this instead simple orients the direction of a set magnitude gravity against the normal plane extracted from directly under the player. If that doesn't make sense to you, try reading this article in depth:
What this means, is this gives us a VERY stable platforming engine, which works in 360 degrees, and gives us that desired "gravity", without having to worry about the variables effects of gravity sources being too much or too low; jump strengths are always exactly the same, and will travel the same distance. Likewise, without the need for point-mass sources of gravity, you can do all sorts of crazy shapes & sizes of planetoids, and the gravity should simulate properly.
In order to account for error in the cases where the raycast shoots down but misses the planet due to the new orientation and finite distance traveled in pixels, skipping a ledge, the engine uses predefined "Tether" points as a backup plan if the normal projection fails. In theory, we could just record the last *good* location of contact with the ray, and shoot towards that in failure and completely forgo the tether points, but thats something you'd have to program on your own, since I ran out of variables as TGF only gives me 3! Likewise, it would require some other scheme to move from planetoid to planetoid, since you would never flip to a different surface.
Whatever. Feel free to use the engine in your games, just make sure to credit Pixelthief! This is a *much* simpler approach than my other engines, so it wouldn't be cumbersome to work with. Take a look at the code and try to understand what makes it tick! I might use it myself....
Move with left/right arrow keys!
Jump with the Shift button!
Try triple jumping/launching/etc!
Review This Download
http://claniraq.googlepages.com/GravityEngine.zip (800.12 kb )