How do I get 3D camera's transform cordinates, and how do I change them.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Laimis

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

:bust_in_silhouette: Reply From: Zylann

To get the Z position, you can write this:

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

print(camera_transform.origin.z)

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