godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.88k stars 20.15k forks source link

RemoteTransform set to global rotation probably sets local rotation on target #56178

Open balintbarna opened 2 years ago

balintbarna commented 2 years ago

Godot version

3.4.1 stable

System information

Windows 11

Issue description

I have the equivalent of the following node tree setup:

In the test scenario, the child's rotation is 0,0,0; the remote's rotation is also 0,0,0 in local space. Body gets rotated based on mouse movement. In the real scenario, child also gets rotated by parent_orientation_setter which calculates a global space orientation based on the current state of ARVR nodes (it guesses player orientation based on HMD orientation and the relative positions of the controllers). I want remote to give its global orientation, which is the assumed orientation of the physical player, to the target node. The target node will use its own orientation to move its parent, body, based on its own forward and right directions. This is needed, because in VR the physical orientation of the player can differ from the VR root's, and therefore the root body's orientation, and delegating responsibilities to separate nodes makes the code nice, hence having a mover node, which is called target in the example.

Now the bug seems to be that the local orientation of my target equals the global orientation of my remote. This seems like unexpected behavior for me, as I'd expect it to be either local-to-local or global-to-global. In the example I mentioned above, I used the Remote scene tree to debug the scene. body has a local rotation of 0,-36.5,0; child has a ZERO local rotation, remote has a ZERO local rotation, remote is set to global and rotation only, and target has a local rotation of 0,-36.5,0, making its global rotation twice as much as that of the remote's. I don't think it makes a difference, but child has a scale of 0.912 on the Y axis.

Steps to reproduce

Create a scene as described above and rotate your root body around.

Minimal reproduction project

No response

Calinou commented 2 years ago

@balintmaci Please upload a minimal reproduction project to make this easier to troubleshoot.

balintbarna commented 2 years ago

@Calinou https://github.com/balintmaci/Godot-Remote-Transform-Debug-Project Please see README for more info.

I made a mistake in the original ticket, I just realized that scoop has not gotten the 3.4.2 binaries yet, so I'm still on 3.4.1.

balintbarna commented 2 years ago

@Calinou also here's my homegrown PullTransform class (as opposed to RemoteTransform which pushes its transform), which seems to work correctly in this scenario, although I have not tested it in other scenarios. https://github.com/balintmaci/VR-Demo/blob/restructure_vr_player_scene/general/PullTransform.gd