Need help with advanced wall-tracing movement

0 favourites
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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...

    <img src="https://dl.dropboxusercontent.com/u/105711543/example.png" border="0" />

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

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

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

  • Wow this work is impressive, i will be really happy to use it in my current project!

  • 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?

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

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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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)

  • Ok, I think I have it working pretty well... I started with sqiddster's Gravity tutorial: scirra.com/tutorials/273/how-to-make-a-gravity-based-platformer

    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: rieperts.com/games/forum/Wall-Tracing.capx

  • AllanR - I like that example.

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

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

    rieperts.com/games/forum/Wall-Tracing.capx

  • - 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!

  • 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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)