The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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

_process(delta):
     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 :(

in Engine by (367 points)
edited by

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

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.

1 Answer

0 votes
Best answer

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))
by (367 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.