I'm trying to calculate the angle between my characters Z axis and the cameras Z axis. How would I go about doing this, and does Godot have any build in methods to make it any easier?

+1 vote

I'm trying to calculate the angle between my characters Z axis and the cameras Z axis. How would I go about doing this, and does Godot have any build in methods to make it any easier?

EDIT: For Vector2 is `angle_to`

, but z axis?

If is for Vector3, just checked and Vector3.angle_to is on Godot 2.1.1

It appears on internal editor's docs (with no details) but are not on the website yet.

Reminder: in Godot, the Camera's Z axis is backwards due to OpenGL convention.

I would go for eons solution once you have the two vectors.

And indeed... the function exists https://github.com/godotengine/godot/blob/master/core/variant_call.cpp#L1493

But it's not in the docs :|

On **Godot 4** the object **Vector2** provide the method **angle topoint(Vector2)**. Objects based in

```
self.rotation = self.position.angle_to_point(forwardPosition);
self.rotation_degrees = self.rotation_degrees + 180; #optional, for fit
```

- All categories
- Engine 33,391