func _process(_delta):
L_KPI.rotation.y = deg_to_rad(STEERING_ANGLE)
R_KPI.rotate_object_local(Vector3(0,1,0), deg_to_rad(STEERING_ANGLE))
L_KPI rotates to the degree specified, which is what I want, but it rotates on global y, I need it to rotate local y. R_KPI rotates local y as I wanted, but it keeps rotating, it keeps adding. Is there a method to rotate to the specified degree but on local y?
What you do in the process function will execute every frame. So, the second line rotates the local transformation by additional STEERING_ANGLE every frame. Now, for the first part, as I can see in the docs Node3D — Godot Engine (stable) documentation in English, rotation is a Vector3 that stores Euler angles of rotation in local coordinates, but it doesn’t say that the second coordinate of the rotation vector (rotation.y) is the angle of rotation about its Y axis. You could try changing the rotation_order property: Node3D — Godot Engine (stable) documentation in English to see if that fixes things.
You could also try L_KPI.rotation.x = deg_to_rad(STEERING_ANGLE)
to see if the first coordinate of the rotation vector corresponds to the y coordinate .
I changed y to x and it still acts like global rotation (no change in values on the other 2 axes). It’s crazy why there’s no straight forward method (if at all) to set the value to local axes of an object.
What happens when you do the rotation in the inspector? Does it rotate as you expect?
I changed rotation modes and came across quaternion which seems like acting as local rotation. I need to test it with visual axis to confirm it though. It’s just like rotation.y, instead you type quaternion.y
You can try that for sure, but I doubt that is the problem. The problem could be that your local coordinate system is actually parallel to the global one, and that you just use rotation to position your node. In that case, changing rotation will change it with respect to the original local coordinate system which is parallel to the global one.
Also, I highly recommend testing Transform parameters in the inspector, since setting rotation in code should have the same effect.
You shouldn’t manipulate quaternion properties directly, unless you really know what you’re doing.
Can you describe in short what you’re trying to implement? Because rotation
property should be the local transform rotation, so I don’t understand where your problem originates.