Clipping-free smooth grid movement

Get help using Construct 2

Post » Fri Sep 30, 2016 5:05 am

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

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

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.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Fri Sep 30, 2016 5:43 am

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.
Mistakes were made.
B
52
S
26
G
108
Posts: 1,605
Reputation: 61,131

Post » Fri Sep 30, 2016 6:12 am

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
Mistakes were made.
B
52
S
26
G
108
Posts: 1,605
Reputation: 61,131

Post » Fri Sep 30, 2016 6:35 am

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.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 25 guests