How to initialize the position of an object

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

Hi,
I am not an experienced GODOT user. Actually I use the engine for less than a month
The answer for me, is to initialize the position in the _ready function
But it is not working in my project.
Please view this video. You can see the orange platform, to start from the upper left of the screen and not from the first waypoint as it should be

Here is the code in _ready function:

func _ready():
if waypoints == null:
	set_physics_process(false)
	return

position = waypoints.getStartPos()
targetPos = waypoints.getNextPos()
timer.wait_time = 1.0

The project is very small and can be downloaded here

:bust_in_silhouette: Reply From: Inces

In Godot position property means local position, while global_position defines position in objective coordinates.
I suspect this is the problem here, even not knowing your getters.
Try replacing position with global_position in both scripts everywhere

I tried but it does not work

ge-orgio | 2022-07-10 19:26

:bust_in_silhouette: Reply From: ge-orgio

I set a breakpoint in the _ready function and initialized the position.
As you can see in the image bellow the position values are not updated

Are You not overriding position in process() ?
Make several prints instead breakpoints, it is much easier to debug

Inces | 2022-07-10 20:52

:bust_in_silhouette: Reply From: the_maven

In the Project Manager, go to the Asset Library Projects, and download any 2D Physics Platformer.

The scripts there will give you and idea how it can be done.

Thank you but I prefer to find where I am wrong. I think this is the best way to learn.
I followed the basic rules of GODOT and my script does not work and I am wondering why
Also I noticed that debugger does not work as I expected and does not helping me

ge-orgio | 2022-07-10 20:07