0 votes

Hello, I'm trying to get 3D camera's Z coordinates, but godot only let's me write this.

var cameraZ = get_parent_spatial().get_node("3D_Camera").get_camera_transform().translated()

Any feedback would be appriciated

in Engine by (15 points)
retagged by

1 Answer

+1 vote
Best answer

To get the Z position, you can write this:

var camera_transform = get_parent_spatial().get_node("3D_Camera").get_camera_transform()


I'm not familiar with get_camera_transform: https://docs.godotengine.org/en/stable/classes/class_camera.html#class-camera-method-get-camera-transform
This one apparently can't be modified, so the only one you can modify is the node's transform:

var camera = get_parent_spatial().get_node("3D_Camera")
camera.transform.origin.z += 10
by (28,744 points)
selected by
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 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 webmaster@godotengine.org with your username.