camera.FORWARD?

Godot Version

4.X

Question

Trying to get the camera FORWARD vector (direction it is looking at).

I tried self.FORWARD and it errors.

Invalid get index 'FORWARD' (on base: 'Camera3D (cam.gd)').

But this page says FORWARD is a constant that a camera should have:

https://docs.godotengine.org/en/stable/classes/class_vector3.html#class-vector3-method-abs

Any ideas?

It says it’s a constant of Vector3 not Camera

FORWARD is a property of the Vector3 class itself, which means if you want to use it you need to write Vector3.FORWARD. Vector3.FORWARD is simply Vector3(0, 0, -1), which is probably not what you need. I think what you want is instead -self.basis.z (or just -basis.z)

1 Like

There is no FORWARD constant inside Camera3D, it is in Vector3, like position.FORWARD

So…how can I get a vector of the direction the camera is facing?!

Any easy way to get this in Godot?

Try camera.global_basis * Vector3.FORWARD

See your other thread you made with the same question Rotated camera how to go forward in camera viewpoint? - #4 by athousandships