How do I lock x value of camera?

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

I have an interpolated camera that follows a position3d, but I don’t want either to move on the x axis. I would try setting the global x value to 0, but that doesn’t seem possible.

Show what you tried, because setting the x value to 0 is definitely possible.

kidscancode | 2019-08-13 21:51

I can set the x value just fine, but it is a child of the moving player. So the value changes based on the player position. This is why I want to change the global x value to 0, but that doesn’t seem to be an option.

andersmmg | 2019-08-14 01:33

:bust_in_silhouette: Reply From: kidscancode

Global position is set with global_position:

$Camera.global_position.x = 0

I tried this, but it doesn’t work.
Invalid get index ‘global_position’ (on base: ‘Position3D’).

andersmmg | 2019-08-14 02:04

You said "Position2D’ in the question.

A Spatial node’s location in 3D space is set via its transform.

global_transform.origin.x = 0

kidscancode | 2019-08-14 02:08

Thanks, that worked!

andersmmg | 2019-08-14 02:14