Need help with advanced wall-tracing movement

Get help using Construct 2

» Wed Jan 29, 2014 9:51 am

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=3
and 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
B
99
S
35
G
20
Posts: 438
Reputation: 17,940

» Wed Jan 29, 2014 12:19 pm

@AllanR - I like that example.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,902

» Wed Jan 29, 2014 4:55 pm

@RamPackWobble - Thanks! I sure learned a lot doing it! The tutorial that I based it on sure had some serious bugs. I might turn my example into an updated tutorial...
B
99
S
35
G
20
Posts: 438
Reputation: 17,940

» Thu Jan 30, 2014 3:08 pm

@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...

www.rieperts.com/games/forum/Wall-Tracing.capx
B
99
S
35
G
20
Posts: 438
Reputation: 17,940

» Tue May 13, 2014 7:55 am

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...

http://www.rieperts.com/games/forum/Wall-Tracing.capx

please make this into a tutorial! Your caps is helping me make sense of the wall hugging gravity so much more than anything else I have found! Thanks for posting this!
B
12
S
2
Posts: 57
Reputation: 799

» Tue May 13, 2014 10:08 am

@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?
B
12
S
2
Posts: 57
Reputation: 799

» Thu May 15, 2014 5:43 pm

@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).
B
99
S
35
G
20
Posts: 438
Reputation: 17,940

» Sat May 17, 2014 2:10 am

@AllenR Thanks, I got it up running. I didn't change anything what so ever... it just started to work... Im very confused by construct still lol. But thanks for the reply!
B
12
S
2
Posts: 57
Reputation: 799

Previous