4ian / GDevelop

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

Scale tween doesn't correctly align object to grid #4271

Open ghost opened 2 years ago

ghost commented 2 years ago

When you use a tween to scale an object down to 0, then move it to a new position and scale it back up again, it doesn't align properly to the grid as expected. Here's an example:

image

Peek 2022-09-06 10-27

The player is scaled down to 0, then moved so that its center aligns with the center of the portal object (the grid and all objects in this example are 50x50px). It's then scaled up, but as it's somehow off-center, it collides with the enemy objects and dies.

This shouldn't happen, as the player can fit nicely on the portal object without touching the enemies:

Peek 2022-09-06 10-29

The discussion around this issue in https://forum.gdevelop.io/t/scale-tween-doesnt-properly-align-object-to-grid/41974 seemed to suggest it might be a bug...

ghost commented 2 years ago

As per the linked forum topic, this can be solved using this additional event:

image

But I'd expect it to work like this without needing to specify that additional action...

AlexandreSi commented 2 years ago

Hi @BWPanda, Thanks for taking the time to report this.

Could it be possible for you to send over the project of the example you used to make the gifs?

Would be way easier for us to debug.

ghost commented 2 years ago

No worries. I kept it around just in case: scale_tweening.zip

AlexandreSi commented 2 years ago

At first glance, it's not a problem with tweens but a rounding problem: When setting the object position by its center, a few computations are made and javascript has trouble computing round values for positions:

image

You can see that it's not a problem due to tweens with the following event:

image