How to use QUATERNION (SLERP) in GDScript

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rxel
:warning: Old Version Published before Godot 3 was released.

Can anyone please post a code example how to make
proper use of Quaternion (especially SLERP) in GDScript?
Thank you in advance!

:bust_in_silhouette: Reply From: vinod

I’ll post an example code here

var lookDir = get_node(lookTarget).get_transform().origin - t.origin 
var rotTransform = t.looking_at(lookDir,Vector3(0,1,0))
var thisRotation = Quat(t.basis).slerp(rotTransform.basis,value)
value += delta
if value>1:
    value = 1
set_transform(Transform(thisRotation,t.origin))

You can take a look at here for a detailed math.
http://codetuto.com/2016/01/godot-engine-movement-and-rotation-basics/

Very special thanks for this information and your answer!

Rxel | 2016-05-19 14:56