godot
godot copied to clipboard
"Use snap (Y)" behavior is inconsistent
Tested versions
4.3-dev5
System information
Windows 11 - Godot 4.3-dev5 Vulkan
Issue description
The "Use Snap (Y)" function does not work well in my project. I sometimes have to enable it for the translation gizmo to behave without snapping and sometimes, it work as expected (ie, to button state is not always corresponding to the real snapping mode).
I'm facing this annoying problem since weeks but I'm not able to find a scenario to reproduce it consistently...
Steps to reproduce
That's the problem, I can not find any reproductible scenario. What I can say is that my project have a custom EditorNode3DGizmoPlugin and a EditorNode3DGizmo but I'm not sure it is the source of the problem since I faced this problem while moving objects around using the translation gizmo... I think a faced this problem also in the "GodotXR Tools Demo" but I'm not sure.
Minimal reproduction project (MRP)
Sorry, I'm not able to provide this :(
I was just about to create this issue. It's been there for a while. I have this problem at least for 4.1+.
Here's what is happening as far as I figure out. When you create a node with the shortcut "Control + A", the snap will stay flipped. It'll think you are still holding control.
But if you press "Control" or "Shift" once anywhere (while not dragging the node).
It'll fix itself and go back to normal behavior. That's why it feels inconsistent.
The Create Node shortcut probably forgot to update the control key status.
Here's a minimal example. Create a node with Control+A and try to move it.
At the end, I press and release the "Shift" key, and try to move it again. And it works normally.
@GustJc It's great you figured out the problem. I can confirm the minimal example reproduce the problem. Thanks :)
The issue comes from Node3DEditor::snap_key_enabled
member which is not always updated. This member variable caches the state of the CTRL key as @GustJc guessed.
When using shortcuts like CTRL+S
or CTRL+A
, the current implementation leave snap_key_enabled
at true
which makes bool is_snap_enabled() const { return snap_enabled ^ snap_key_enabled; }
return a flipped value because of the XOR.