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

The last Bone2D in the chain will scale incorrectly #80643

Closed
thiagola92 opened this issue Aug 14, 2023 · 0 comments · Fixed by #91731
Closed

The last Bone2D in the chain will scale incorrectly #80643

thiagola92 opened this issue Aug 14, 2023 · 0 comments · Fixed by #91731

Comments

@thiagola92
Copy link
Contributor

thiagola92 commented Aug 14, 2023

Godot version

v4.2.dev3.official [013e8e3]

System information

Ubuntu 23.04 x86_64

Issue description

When scaling the last Bone2D from the chain, there is a specific case where the bone length will be more than expected.

The main logic is to use the lower value from scale MIN(get_global_scale().x, get_global_scale().y):

rel = Vector2(cos(angle_to_use), sin(angle_to_use)) * (length * MIN(get_global_scale().x, get_global_scale().y));

But this can go wrong when the lower value is negative, attention for (-1, 3) and (1, -3):
image

Note: This can easily be fixed by getting the absolute value from scale.

rel = Vector2(cos(angle_to_use), sin(angle_to_use)) * (length * MIN(ABS(get_global_scale().x), ABS(get_global_scale().y)));

Note 2: (1, -3) and (-1, 3) are equal after saving the project because the project reload information from transforms and the (-1, 3) is convert to (1, -3).

Steps to reproduce

  • Create a scene with Node2D as root
  • Add a Skeleton2D
  • Add a Bone2D
  • Scale Bone2D by (1, -3)

Minimal reproduction project

N/A

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