4ian / GDevelop

🎮 Open-source, cross-platform 2D/3D/multiplayer game engine designed for everyone.
https://gdevelop.io
Other
10.81k stars 848 forks source link

Platformer: Jump through platforms collision behaves incorrectly on certain pixel value #976

Closed CustomLenny closed 5 years ago

CustomLenny commented 5 years ago

Describe the bug

Default platforming behavior (and I'm guessing a pixel perfect calculation) that causes the wrong behavior on the jump through of a platform at a certain height. Changing jump speed and such can solve it, but by default this shouldn't happen and probably comes down to the order of operation in which the collisions are checked upon when jumping.

To Reproduce

Setup default value platformer character and jump through platforms. Alt step. change default controls so that jump can only be pressed once. Place a platform so that the top is 64px above the top of the platform below it. Jump through platform.

EITHER: with default controls the character will jump sky high as it gets a second boost off the platform above it (only at 64px) OR: with controls of jump ones only the player will get sucked onto the platform.

DOWNLOAD OF SETUP EXAMPLE: Issue.zip

Other details

gdevelop 5, beta 65, running in gdevelop

4ian commented 5 years ago

This example is very clear 😍Thanks for taking the time to create it. So yeah there seems to be an issue when the platform is exactly at a certain position, not sure why but I'll check! (any help is welcome though)

EDIT: this is not related to the height of the platformer character. I think it could be something like gravity/jump force are reached a certain value that cause the object to think it's on a floor.

CustomLenny commented 5 years ago

Correct the platform character size does not effect it.

Just an update as I thought of something, I tried move the platform by .1px and also .5px, the issue still happens even when the character is not set to round coordinates, I thought it could have been to do with it matching the exact same pixel value and thinking that he was then standing on the ground.

But yeah, took me a long time to figure out that this was a problem at that height, I couldn't understand why he kept zooming.

4ian commented 5 years ago

Adding 0.5 to the Y coordinates of the "64" platform (to get 416.5) give the same issue, but if you remove 0.5 (to get 415.5) (or add/remove 1), then the issue is not showing anymore.

Can you confirm this?

CustomLenny commented 5 years ago

Can confirm. And a little something else on top of that, anything after 416.6 works correctly, and some numbers fractionally below it, but still happens at 416.52999, so it doesn't stop after .5, but somewhere between .5 and .6.

CustomLenny commented 5 years ago

Issue2.zip Ok, here's something that is related, but this is at a different height. May take a couple of goes to reproduce. Walk the character left into the block (this lines it up at the pixel it happens at). Jump, character gets sucked onto slanted block, only at that position though. And it is a different height than the 64 block.

CustomLenny commented 5 years ago

Issue3.zip I'm unsure if I saved that last one correctly, but here it is with two examples, either go to the left to the block and jump, or right to the right block and jump, sucked both times. ALSO if you push left off the top of the 80 block and fall off the 80 block, you will pass straight through the slanted 64 block most of the times.

CustomLenny commented 5 years ago

Is this a problem in gdevelop or in pixi.js?

4ian commented 5 years ago

GDevelop, in the platformer engine extension. Sorry I did not have the time to check more into this since then :/ Any help in the debugging is welcome, probably some corner case in the JavaScript code of the platformer, related to how floor platform are handled, but not sure what exactly.

4ian commented 5 years ago

@CustomLenny I found the issue :) If your character/object was precisely "on" a jumpthru platform will jumping, the platformer engine would land your object on it. I added a condition to make sure that it's landing only if the object is not going up in the air. Tested and seems to work properly in all cases (see fix in #1171). Fix will be in the next version :)

CustomLenny commented 5 years ago

Ah you beat me to it. Very cool. I was actually going to 'program' that into the character in gdevelop to fix it, to make it only contact when falling, but this is a much better solution. :P Thanks very much.