Attention |
Topic was automatically imported from the old Question2Answer platform. | |

Asked By |
kitfox |

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?

Have you already looked at the `to_local()`

and `to_global()`

functions?

Ertain | 2020-11-13 00:28

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

kitfox | 2020-11-13 07:36