Zshandi / ScalingPuzzler

Scaling Puzzler game for the 2024 GMTK Game Jam
0 stars 0 forks source link

Fix scaling physics #52

Closed Zshandi closed 1 week ago

Zshandi commented 2 weeks ago

Currently, how the scaling works is that the ball shrinks in size, and the camera zooms in to match. However, this method of scaling has a limit to how small we can go due to how the physics engine works. Beyond about 2^14 scale it begins to break down completely (see video), but before that there is the issue of the ball being partially in the ground and not getting moved out. The problem with the ball being in the ground is due to the physics having an allowable margin of intersection, while the breaking down is likely due to floating point precision errors at those small scales.

The easiest and best way to fix this would likely be to just have the level scale instead of the ball, as we originally had it set up. Most of the code for this functionality is still in place, just not attached to anything or called into. However, it needs to be adjusted so the center of scaling is always just the balls position, not the mouse position. The other thing is that the current tiling shader code will need to be adjusted to account for this, as it currently uses the camera zoom for scale, and global position for position (as opposed to local space).

EDIT: I fixed the shader so it combines the zoom and local scale, and uses local position!

https://github.com/user-attachments/assets/87a624e2-acb9-40b6-9af8-e03eecc9f232

Zshandi commented 1 week ago

Although it's much more stable than it was, it still isn't able to scale much past where we were previously able to. To account for this, we would need to do more drastic rework of the scaling functionality, so will need a separate issue.

Ideas for how to fix this: