0 votes

I have a vector that is defined in the local space of one object and I'm trying to figure out how to transform it into another objects's local space (ie, what direction is the camera's basis.z vector pointing from my player character's point of view?). Mathematically this should be pretty straight forward - in pseudo code, I would just need to solve:

remapMatrix =  player.localToWorldMatrix.inverse() * camera.localToWorldMatrix
relativeDir = remapMatrix.vectorTransform(camera.transform.basis.z)

The trouble is, I cannot find any equivlents of get_local_to_world_matrix() or vector_transform() in the Godot API docs (a vector transform is different from a point transform - a vector transform ignores the origin of the transform matrix).

How would I do this in Godot?

in Engine by (154 points)

Have you already looked at the to_local() and to_global() functions?

Yes. I believe those are for points, not vectors.

Please log in or register to answer this question.

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.