Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move_and_* does not work for pixel perfect collisions #38709

Closed
Max-Hollywood opened this issue May 13, 2020 · 4 comments
Closed

move_and_* does not work for pixel perfect collisions #38709

Max-Hollywood opened this issue May 13, 2020 · 4 comments

Comments

@Max-Hollywood
Copy link

Godot version: 3.2.1.stable.official

OS/device including version: Windows 10.0.18362

Issue description: building top down grid like movement game, move_and_slide/move_and_collide add erroneous position data so it moves out of being pixel perfect. So if x, y position vector of 32,24 would become 32.01216, 24.9389 if told to move_and_slide/move_and_collide.

Steps to reproduce: tiles are 16x16, CollisionShape Collision2D is 16x16, and using move_and_* means that the node has a float position, causing the collision shapes to meet, causing the movement to stop.

Minimal reproduction project:
For reference, here's the level:
godotmoveref

This is the issue when move_and_* is called:
godotmove

The position according to Godot remote:
godotissue

My solution is to have a smaller collision shape and an additional test move_and_collide and if there is a collision then don't move, and have a final round() when the node stops moving, to snap it back to pixel position.

@TheDuriel
Copy link
Contributor

TheDuriel commented May 13, 2020

Godot is inherently incapable of pixel perfect collision. If you want that, you'll need to write a physics engine based on Intergers and AABB tests exclusively.

So this isn't a bug, nor unexpected. You'll find this to be an issue with any Engine which does not feature a custom, pixel perfect, physics Engine.

I recommend you keep faking it. Like the entire rest of the games industry that rely on premade Engines.

*Note that the new Interger based vector types in 4.0 will make it easier to write your own physics handler for this kind of stuff.

@Zireael07
Copy link
Contributor

To add to what @TheDuriel said, I believe 99% of pixel perfect games out there don't use physics at all, instead just changing transforms by hand.

@Calinou
Copy link
Member

Calinou commented May 13, 2020

Duplicate of #37798 and #23140 (the underlying issue is the same).

@Max-Hollywood
Copy link
Author

Something I forgot to mention that you might already be aware of, which did contribute to this, was that the move_and_slide perpetually moved downwards. On my tilemap, the node ends up further down and to the left of it's final resting position, instead of "in the center" of the tile. This may be part of a tilemap issue, which I'm about to create an Issue for. With both of these issues I can't make any levels larger than the screen area because the player gets stuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants