Why does slerping between local transforms cause errors?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Arandual

So I ran into a weird issue.
When attempting to slerp between two vectors I got a set_axis_angle: The axis Vector3 must be normalized error.

I tried normalising all vectors but it still caused this error to happen.

To my surprise it went away when I used get_global_transform.origin.
This doesn’t result in what I intend to do, but for some reason when I use get_transform.origin (a.k.a. local location) it throws this error.
Why? And is there any way to fix it?

Maybe showing us the code would help?

Ertain | 2020-07-01 23:35

Of course @Ertain!
I will also share the relevant node structure.
But this is the code in question:

var tpLocCurrent = tpCheck.get_transform().origin
var tpAnim = tpLocCurrent.slerp(orient*tpDistance, 0.12)
tpCheck.transform.origin = tpAnim

Note that all variables here are Vector3 types and orient is a vector based on user input that keeps track of where the character is facing. And tpCheck refers to the TpCheck area node.

So basically I have a marker as part of my player scene.
This marker is always ahead of the player and marks where the player will teleport to.
This is the node structure:
node structure

Weirdly however when I replace:

var tpAnim = tpLocCurrent.slerp(orient*tpDistance, 0.12)

With:

var tpAnim = tpLocCurrent.linear_interpolate(orient*tpDistance, 0.12)

It works completely fine and causes no errors, but it isn’t exactly the effect I am looking for.

Oh and finally the code given at the start works, exactly as expected with no side effects.
But for some reason it just keeps throwing those errors.
And when I used a global position for tpLocCurrent (see below) instead, it stopped giving those errors…
But it doesn’t work as intended at all.

var tpLocCurrent = tpCheck.get_global_transform().origin

I also tried to use .normalize() on all vectors involved but it didn’t help either.

Regardless thanks for the reply, have a nice day!

Arandual | 2020-07-02 06:50