Just learning Godot and GDScript but can't see why the label moves faster when travelling from right to left than left to right in this script. I inserted some variable to check the min and max delta values when travelling in each direction and there's no real difference. The project consists of a single node with just the label as a child. What am I missing (I appreciate the label goes off screen to the right but that's not the issue :D ) ?

extends Node var speed = 200 var dir = 1 func _ready(): pass func _process(delta): var temp = get_node("Label").rect_position temp.x += speed * dir * delta if (temp.x < 1) or (temp.x > get_viewport().size.x): dir = -dir temp.x += speed * dir * delta get_node("Label").rect_position = temp

Thanks in advance,

I do not think it is moving faster, but rather it seems to be moving faster. I changed the script to use the label to print the distance between each movement, and it seems to be fixed around 3.3 no matter which way it is going. Here is the script I used:

extends Node var speed = 200 var dir = 1 var last_position; func _ready(): pass func _process(delta): var temp = get_node("Label").rect_position var temp_size = get_node("Label").rect_size last_position = temp; temp.x += speed * dir * delta if (temp.x < 0) or (temp.x > get_viewport().size.x - temp_size.x): dir = -dir temp.x += speed * dir * delta get_node("Label").rect_position = temp get_node("Label").text = str(last_position.x - temp.x).left(6);

I agree that it looks to be moving faster, but I think it is a illusion. The difference in positions does not seem to be changing from direction to direction. At least, that is what I gather from my testing :smile:

Edit: Also, I changed the script slightly so it does not go off screen so I could read the label the entire way. Feel free to remove it if you want

Thanks for the reply. I asked someone else to put a stopwatch on it and as I thought, there's almost a second difference when it's moving right to left. I tried it running from the IDE and building as a (linux) binary with the same result. Also hard- coded the max x value in case the call to get_viewport().size was having an effect.

I'll stick in a timer to get time elapsed when moving between two fixed points in each direction....

Here we go, almost 1 sec difference:

extends Node var speed = 200 var dir = 1 var elapsed = 0 func _ready(): pass func _process(delta): elapsed += delta var temp = get_node("Label").rect_position temp.x += speed * dir * delta if (temp.x < 1) or (temp.x > 600): dir = -dir temp.x += speed * dir * delta elapsed = 0 get_node("Label").rect_position = temp if dir == 1: get_node("LabelLeft").text = str(elapsed) else: get_node("LabelRight").text = str(elapsed)

I saw your reply, but was out all day yesterday, so I did not have a chance to test myself. Glad you got it reported, hopefully a fix will be ready soon!

4 years later