Godot Version
Godot 4.1 + Voxel Adon
Question
Hello I am trying to create a space game, in this game I set the players transform.basis in order to keep them oriented downwards to the planet. This is working with the following code:
transform.basis.y = (transform.origin - planet.transform.origin).normalized() + mouse_mov
transform.basis.z = transform.basis.y.cross(Vector3(1,0,0)).normalized()
transform.basis.x = transform.basis.y.cross(Vector3(0,0,1))
The problem I have a _unhandled_input function that controls player look. I originally had the Y rotation of the player get changed by the movement of the mouse on the x axis. However after setting the basis on the 3 axises I can no longer rotate the player on the y axis. I have tried the following methods:
transform.basis = transform.basis * Basis(transform.basis.y,-event.relative.x*0.005)
transform = transform * Transform3D(Basis(transform.basis.y,-event.relative.x*0.005),Vector3(0,0,0))
rotation.y += -event.relative.x*0.005
rotate(transform.basis.y,-event.relative.x*0.005)
rotate_object_local(transform.basis.y,-event.relative.x*0.005)
transform.basis = transform.basis.rotated(transform.basis.y,-event.relative.x*0.005)
I assume this has to do with me already setting the basis to something else an so the basis is locked. How ever I can’t really seem to think as to how to integrate the mouse motion into the basis setting. I also need to set the basis so the player can stay on the planet (-y basis is gravity).
Eventually I would also like to have the planet move and the player stay with it without a parent child relationship as I want to be able to move to other planets. I originally thought that doing transform * planet.transform would do it but the player then fails to rotate properly again.