0 votes

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.

asked Aug 13 in Engine by andersmmg (86 points)
edited Aug 14 by andersmmg

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

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.

1 Answer

+1 vote
Best answer

Global position is set with global_position:

$Camera.global_position.x = 0
answered Aug 14 by kidscancode (10,848 points)
selected Aug 14 by andersmmg

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

You said "Position2D' in the question.

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

global_transform.origin.x = 0

Thanks, that worked!

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.