Godot Version : 4.4
Hello again!
I am having trouble trying to rotate the Y axis of a Rigidbody3D locally. The code I’ve written works, but, only when there is no X or Z rotation. Otherwise, with any XZ rotation, it rotates the given Y globally and additionally for some reason cannot face backwards globally anymore:
var last_direction : Vector2 = Vector2.UP
func _physics_process(delta: float) -> void:
var input_dir := Input.get_vector("left_key", "right_key", "forward_key", "backwards_key")
if direction:
last_direction = (Vector2(input_dir.x,-input_dir.y)).rotated(cam_arm.rotation.y).normalized()
var r_x : float = 2.0
var r_y : float = lerp_angle(rotation.y , -atan2(last_direction.x, last_direction.y) , delta * 5)
var r_z : float = 2.0
rotation = Vector3(r_x, r_y, r_z)
(I just pasted the relevant code here, feel free to ask if more info is needed)
I wanted the local Y rotation to smoothly face the last_direction vector. I’ve made the test X and Z separate global_rotations while the Y stayed a separate rotation, though it still behaved similarly. Additionally, there are no other rotations being applied to the RigidBody3D then what is shown here, and all angular axis are locked in the RigidBody3D’s PhysicsBody3D’s Axis Lock.

