Ok, I think I have it working pretty well... I started with sqiddster's Gravity tutorial: https://www.scirra.com/tutorials/273/how-to-make-a-gravity-based-platformer?page=3and expanded on that... Gravity Zones tell it which way gravity goes. If zones overlap it calculates the average angle of gravity. There are two types of gravity zones: Relative and non-relative. Relative ones send gravity to a single point, so they work around curved objects (there is a semi-circle and round variation). Non-Relative zones work along flat surfaces and send gravity in the angle of the zone (these zones have an arrow so you can tell which way it goes - you can rotate them to any angle you need).

The pink bars are gravity reversers. When the player or wall hugger hit one their gravity changes 180 degrees.

The wall huggers go in the initial direction they are told to until they hit a blue direction changer. If they hit a green jump box, they jump. Usually when they get to the opposite side of the jump they are upside down, and by the time they get turned around they are not on the jump box there (but sometimes they turn around too quick and then jump right back).

The main problem is that collision boxes don't come in circles, so for the round objects I made the collision box as close to round as possible, but when players and wall huggers go over the corners of the collision box they briefly think they are in the air, and they can't jump if they don't think they are on the ground. So, there are many times the wall huggers will go right past the jump boxes (usually on the round object but I have seen it on flat parts a couple times too).

It is also real easy for the wall huggers to get stuck - you have to be pretty careful how you line up the floors, and sometimes the gravity zones (the inside corner on the L shape was tricky).

Over all, the code is fairly simple - C2 does almost all the work... it is only 24 events! And it seems to run pretty smoothly, although it is doing a lot of collision checks.

One other slight issue - the rotating square moves, but the gravity zones around it don't, so that confuses the two wall huggers on it a little. If you want moving surfaces, you either have to have the gravity zones move with the surface, or set them up in a way that works (and doesn't interfere with other zones)...

you can get the capx file at: www.rieperts.com/games/forum/Wall-Tracing.capxAllanR2014-01-29 10:20:33

@MadFactory - did you try out my wall-tracing example? It isn't physics based, but does use the platform behavior, which does have simplified physics - so you can control how strong gravity is, how fast they move, how far they can jump, etc...

AllanR wrote:@MadFactory - did you try out my wall-tracing example? It isn't physics based, but does use the platform behavior, which does have simplified physics - so you can control how strong gravity is, how fast they move, how far they can jump, etc...

@AllanR I was playing around with your .capx and so far its the best example Ive found of the wall tracing movement. IDK if you can tell me this or not, but my non-relative Gravity zones just shoot my player off either left or right. Ive tried rotating the sprite several different directions but no matter what it just shoots him off right or left. Everything else works perfectly though, any idea on how to fix it?

@p0tayters, it has been months since I did that, and I don't remember very much detail right now - but I do remember that it took a lot of tinkering to get it working right. It doesn't take much to confuse it and get strange results.

My example tried to average the gravity angle when there were overlapping zones. You may have an issue with how your zones overlap, or a problem with calculating the angle. Or you may have code changing the gravity accidentally when you don't expect it (my 13 year old son is very new to programming and he runs into problems like that all the time).