Slerp doesn't do anything

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

I have a Transform() looking_at a target node and I want to slerp() the basis of a spatial node to whatever the transform is looking_at. But it just ignores the slerp() without any errors coming up. I don’t know what I’m doing wrong.

     var p2_dummy = Transform()
     var p2_look = $Player1.global_transform.origin
     p2_dummy.looking_at(p2_look, Vector3(0,1,0))
     $Player2.global_transform.basis = 
     $Player2.global_transform.basis.orthonormalized().slerp(p2_dummy.basis, delta)

These are the lines that should be rotating it, but it just constantly faces one direction. Please help :frowning:

Why are you casting Player1’s origin to a Vector3? AFAIK, it’s already a Vector3.

Ertain | 2020-05-19 08:44

Thanks for catching that. That was a typo when i was copying it into this forum, I fixed it to better reflect what it is in engine.

Dumuz | 2020-05-19 17:57

:bust_in_silhouette: Reply From: Dumuz

I figured it out.

Transform’s 'looking_at method is a method used to return a transform, so it needed to be applied to the new transform via ‘=’, i.e.;

p2_dummy = p2_dummy.looking_at(p2_look, Vector3(0,1,0))

I thought there was a problem with the look_at() function. But I couldn’t quite put my finger on it. ;-D

Ertain | 2020-05-20 01:24