0 votes

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

Godot version v3.4.4
in Engine by (16 points)
edited by

3 Answers

0 votes

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

by (7,925 points)

I tried but it does not work

0 votes

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

https://www.mediafire.com/view/y5ixpg6xl7nrn88/bandicam_2022-07-10_22-18-01-325.jpg/file

by (16 points)

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

0 votes

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.

by (232 points)

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

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 Frequently asked questions and 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 [email protected] with your username.