Clipping-free smooth grid movement

0 favourites
  • 4 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • I've modified an old capx I found to create a grid system for my gamekit. I feel I've gotten it pretty close to how A Link to the Past runs, if you compare this gif below. I've recorded the below gif with bsnes and licecap, so the example below runs at near 100% accuracy in terms of simulating the SNES. (without accounting for the slight slowdown caused by recording the gif, so it probably runs slightly faster)

    How would I go about getting the smooth movement as seen in this next gif? The gif demonstrates Link smoothly moving into a one-tile wide space, for clarity. The original Legend of Zelda did not have this, as it had clipping issues with attempting to move into a one-tile wide space. As some of you know, you had to be exactly pixel perfect to not clip with things in the NES LoZ.

    From some googling and article research, my guess is to create two feelers on the side of the player's hitbox. One on their left and one on their right, about four pixels away from their own hitbox edges. If there's no collision for both, no position adjustment is needed but if both get collision detections, it'll stop the player's forward progress but if only one feeler has a collision detected, the player will get nudged into the opposite direction until they're aligned with the grid and then continue forward motion.

  • That idea sounds about right. You'll want them as close to the edge as possible though, so they'll be able to help you "clear" the corner. If they are 4 pixels away, then you might get stuck on the 1-2 pixels where the helper sprite isn't colliding so you don't get nudged, but your main sprite is still colliding with the solid object.

    So the helper sprites should be just 1 pixel away from the sides as to prevent the "nudge event" collision conditions triggering from objects to the side, and the amount nudged should be at least 2 pixels to allow you to clear the corner of the object and continue moving forward. You might want 3, one dead center. If the center one is overlapping, then no nudge.

    Assuming you're using something similar to solids and 8-direction behavior.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Never mind, looks like adjacent doesn't count as overlapping after all. Pretty much ignore everything I said in the last post. Experimented a bit and this seems to work: https://www.dropbox.com/s/xgmojljasm5e6 ... .capx?dl=0

  • Thanks for the clarification and further ideas on how to improve the mechanic in theory. Yep, I'm utilizing solid behavior and eight-direction too. Also, since you posted again, thank you for an actual working example. Kudos for going out of your way to show me, man.

    I think I initially visualized this wrong though. I assumed sides even if he was facing forward, but it turns out technically the feeler helpers would be actually both in front and behind him. They get get rotated if he faces left or right, I suppose. I had drawn up a really simple diagram replicating it on paper.

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