content

Quaternion rotation is frame dependent

This code is frame dependent: 1

extends Node3D

var spin := Quaternion.from_euler(Vector3(1, 1, 1))

func _process(delta: float) -> void:
	quaternion *= spin * delta

This is because spin is a Quaternion, and multiplying it by delta only does a component-wise multiplication. This results in frame-dependent rotation, where the speed of the rotation is different depending on how high the framerate is. In order to scale the rotation, use slerp. For example: 2

func _process(delta: float) -> void:
	quaternion *= Quaternion.IDENTITY.slerp(spin, delta)

meta

tags: godot

created:

commit: 6287f83c