Need help with advanced wall-tracing movement

Get help using Construct 2

Post » Wed Jan 29, 2014 1:21 am

I'm looking to make a "wall-tracing" movement like the zoomers/geemers from Metroid, but more complex, and hopefully physics-based. Not only will they move along more types of surfaces (square, circle, slopes) and rotate smoothly around them, but they can do a short hop and cling on to other platforms upon contact, including moving/swinging/rotating platforms.

Like so...



...Unfortunately I've had a really tough time getting this to work. After a week or so of screwing around with it and modifying existing wall-tracing examples, I am stumped.

Anyone else willing to give it a shot?
MadFactory2014-01-29 07:56:05
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Wed Jan 29, 2014 1:41 am

how would it know when to "jump" to another object, rather then just go around the one it is on. In your last example, the red square is on top of the "L" shaped block. Would it circle around that forever after it got to it? Or jump back down and reverse its path? How would it know it can jump to the platform below it, and not all the way over to the circle? If it did jump down to the lower block, would it have to head back to the left, as opposed to continue to the right (and go around under that block) and how would it know not to just jump back to the L shapred block?

(I am just trying to understand all the rules before I try to implement it.)
B
94
S
33
G
20
Posts: 438
Reputation: 17,615

Post » Wed Jan 29, 2014 1:49 am

Sorry I should have mentioned that! It will jump when you click on it, or when it collides with special trigger objects.

It will jump like any other platform character with different gravity angles, and only clings to other platforms upon contact. When this happens it rotates (clockwise or counter-clockwise depending on the direction) until its "feet" are on the ground, and then proceeds. As shown in Example 2, it will always move in the same direction, only turning around when touching special objects. So yes it will infinitely loop around the L-shaped platform at the end of Example 2.
MadFactory2014-01-29 01:56:28
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Wed Jan 29, 2014 2:02 am

Wow this work is impressive, i will be really happy to use it in my current project!
B
4
Posts: 2
Reputation: 204

Post » Wed Jan 29, 2014 7:16 am

Will these walls be "set in stone"- Unmovable?
How many of these wall huggers will there be ?
Will they be able to travel the same section of wall? How fast do you want them to travel ( always the same speed) ?
Will they need to react to player - change direction / chase player?
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
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Wed Jan 29, 2014 7:33 am

I guess a lot of this could be done with overlapping at offset and setting angle accordingly.

you might need extra sprites to detect when corners are reached.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 29, 2014 7:55 am

@RamPackWobble
-Most platforms will be static, yes, but it'd be great if they work with moving platforms too.
-Anywhere from 1 to 10 I imagine.
-Yes they will just walk past eachother on the same wall
-They can have varying speeds
-They don't react to the player at all, but I might have an object to turn them around upon collision.

@LittleStain Yeah I've tried but never got farther than square/rectangular platforms. As soon as the slopes and round surfaces come in I'm lost. Once with just events and once with the platform behavior. I'd really like this to work with physics though..hmMadFactory2014-01-29 07:58:38
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Wed Jan 29, 2014 8:12 am

If you can't use detector sprites for the angles, you might have to insert the angles directly in the code.
On overlapping the circular sprites you could set the angle to angle(circle-center.x,circlecenter.y,player.x,player.y)

I did something like that in this topic (without the circles):
slope angle platform

Based on:
This example in the arcade.

The original capx, just takes angle numbers instead of sprite-angles.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 29, 2014 8:39 am

would this be good enough ? Or would you need it to be smoother/closer ?

Got to go out now - I should be back just after 1GMT

test (needs work)
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
33
G
47
Posts: 1,194
Reputation: 30,812

Post » 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
94
S
33
G
20
Posts: 438
Reputation: 17,615

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests