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

RemoteTransform flips target node upside-down if update_rotation is false #91550

Open
AbstaDash opened this issue May 4, 2024 · 3 comments
Open

Comments

@AbstaDash
Copy link

AbstaDash commented May 4, 2024

Tested versions

Reproducible in:

  • v3.0.stable.official
  • v3.5.3.stable.official [6c81413]
  • v4.0.stable.official [92bee43]
  • v4.2.1.stable.official [b09f793]
  • v4.2.2.stable.official [15073af]
  • v4.3.dev6.official [89850d5]
    • Has the RemoteTransform2D behaving like the RemoteTransform3D, in that it doesn't toggle the target node's scale.y between 1 and -1 when the scale.x is updated, but just keeps it at -1
    • Crashes when loading the MRP

Not reproducible in:

  • v2.1.6-stable
    • Last version I could download before update_rotation was first added. I couldn't download versions v3.0-alpha1 to v3.0-rc3 from https://godotengine.org/download/archive/
    • The target node just flips in the x axis as expected

System information

Godot v4.2.1.stable - Windows 10.0.22631 - GLES3 (Compatibility) - Intel(R) HD Graphics Gen11 () - Intel(R) Celeron(R) N4500 @ 1.10GHz (2 Threads)

Issue description

A node being controlled by a RemoteTransform node will have its y scale set to -1, if

  • The RemoteTransform has a negative scale value on only one axis (eg., global_scale.x < 0 and global_scale.y > 0), AND
  • The RemoteTransform is NOT updating rotation (update_rotation = false)

screenshot_transform2D_target_node_is_flipped

screenshot_transform_2D_target_node_is_not_flipped

This issue occurs with both RemoteTransform2D and RemoteTransform3D nodes. Both of them are solved by switching off update_rotation.

With the RemoteTransform2D, though, the targeted node's y scale will update to either 1 or -1 in a weird way. If I toggle the scale.x value on the RemoteTransform2D from 1, -1, 1, -1, the targeted node's scale.y will be 1, -1 -1, 1.

It's like it checks if the new value is negative or positive, and if it's the same sign (positive or negative) as the current value, it toggles, and if it's not, it is the opposite of the sign of the new value.

When the scale values are printed in the console, they are sometimes inaccurate and better describe the values just before they were last updated.
screenshot_target_node_flipped_but_scale_is_printed_as_1_1

The scale value on the RemoteTransform can be its own or inherited from a parent.

Steps to reproduce

From scratch

  1. Create a new 2D scene
  2. Create a Sprite2D node
  3. Set its texture to the icon.svg file
  4. Create a RemoteTransform2D node
  5. Disable update_position in the Inspector
  6. Set the Sprite2D as the RemoteTransform2D's remote_path
  7. Change the RemoteTransform2D's scale.x to a negative value
  8. The Sprite should flip upside down

With minimal reproduction project

  1. Import the minimal reproduction project .zip as a new project
  2. Run the project or the remote_transform_3D_bug.tscn scene
  3. Press the Spacebar to toggle the parent node's scale.x to 1 or -1. In the 2D scene, with the RemoteTransform2D's update_rotation disabled, it won't actually change any values until the Spacebar has been pressed twice
  4. The broom should flip upside down
  5. In the editor (keep the game window running), select the RemoteTransform2D or RemoteTransform3D
  6. Set the RemoteTransform's update_rotation to true
  7. The broom should now no longer flip upside down when the scale changes

Minimal reproduction project (MRP)

Completely unnecessary but could be convenient.

RemoteTransformMRP.zip

Image Attribution:
gBot_complete.png, from https://docs.godotengine.org/en/stable/tutorials/animation/2d_skeletons.html © Copyright 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0).

@AThousandShips
Copy link
Member

AThousandShips commented May 4, 2024

This is due to a limitation in 2D transforms, see the documentation, unsure why it behaves differently with and without rotation though

@AbstaDash
Copy link
Author

Wow, thanks! That explains a lot!

@AbstaDash
Copy link
Author

AbstaDash commented May 6, 2024

I think I figured it out!

From the documentation you linked, when a Node2D is scaled with a negative x value, it looks like it's flipped on the x axis, but actually

  1. It's flipped on the Y axis and then
  2. Rotated 180 degrees.

With update_rotation disabled, that last step of rotating 180 degrees doesn't happen, leaving it upside down.

I made a 2D test scene and found that, in the editor, the target Node2D has the transform already decomposed (?) into scale.y = -1 and rotated 180 degrees.
in_editor_all_four_sprite2Ds_with_transforms

Interestingly, when run, the Sprite2D that was upside-down in the editor is initially adjusted to have its scale back to (1,1).
running_all_four_sprite2Ds_with_transforms

However, changes to the RemoteTransform2D's scale (if the scale.x is still a negative value) when the game is running will make it turn upside down.

I wonder if some sort of compensation for the rotation could work, so if update_rotation is disabled and the scale of the RemoteTransform has a negative x value, it will add the 180 degrees needed to the transform matrix.

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

2 participants