Yeah, it's finally fixed, I guess. Through talking and trying to explain what is happening, it made me think about how this was implemented back in the days of very low resolution displays and low power machines.
Of course, using integer pixels/frame movements would solve the issue, but movement would be too fast and I wouldn't have much control over the speed, only a few usable speed rates. Originally, I guess in the old days this was implemented using a sub-pixel internal representation of the position that got then rounded to integers before being used elsewhere in the game instead of using sub-pixel placement until the final rendering stage. So why not do that? Since I'm new to godot, I hadn't thought this could be easily done.
I've created a real_position
property in the platform, and I animate that property instead of the position. Then in _physics_process
, I set the position to the rounded value of real_position
. This way, AnimationPlayer uses floats to calculate the position of the platform, but the platform is never at a sub-pixel location, only integers.
I didn't think it could be that easy. And I think I could apply this approach to other future cases.
I guess I could apply it to every object in the game, although the ones using move_and_*
would require a bit more fiddling with the position values. Anyway, my issue was only with the objects using AnimationPlayer because those are the only ones that could drag and push the player.
I'm putting here the example project with the fix in case anyone is interested in this solution. I've tried to find resources to develop pixel perfect games in Godot but they always relied on using high resolutions that hid the issue.
I'm sorry if I haven't done a good job explaining it from the start. I hope it makes sense for anyone else getting here searching for a solution.
Thanks for all the ideas, it's really appreciated.