im trying to rotate a cube like the game bloxorz so im using the local axis, but a want to make a interpolation in quaternion because the euler angle problem but i dont know how to do it.
extends RigidBody
var target_position = Vector3()
var varAlph = 0.0
var basis = Basis()
func _ready():
print($MeshInstance.rotation_degrees)
func _physics_process(delta):
$MeshInstance.rotation = lerp($MeshInstance.rotation, target_position, varAlph)
if varAlph <= 1:
varAlph += .01
if Input.is_action_just_pressed("ui_left"):
$MeshInstance.rotate_object_local(-basis.z, deg2rad(90))
print($MeshInstance.rotation_degrees)
varAlph = 0.0
if Input.is_action_just_pressed("ui_right"):
$MeshInstance.rotate_object_local(basis.z, deg2rad(90))
print($MeshInstance.rotation_degrees)
varAlph = 0.0
if Input.is_action_just_pressed("ui_up"):
$MeshInstance.rotate_object_local(basis.x, deg2rad(90))
print($MeshInstance.rotation_degrees)
varAlph = 0.0
if Input.is_action_just_pressed("ui_down"):
$MeshInstance.rotate_object_local(-basis.x, deg2rad(90))
print($MeshInstance.rotation_degrees)
varAlph = 0.0