Inconsistent movement with delta

My player spawns on a conveyor belt, right in the middle of the bottom part of a “river” that functions like a conveyor belt



These red parts of the river node are area2d collision shapes, and when the player collision enters any of those red lines, it will set a variable such as “in_river_bottem_side” to true, and set it to false when the player exits it


#
#A part of the players script for moving along the river
#
func _process(delta):
	if in_river_bottem_side:
		move_local_x(-river_flow * delta)
	if in_river_left_side:
		move_local_y(-river_flow * delta)
	if in_river_top_side:
		move_local_x(river_flow * delta)
	if in_river_right_side:
		move_local_y(river_flow * delta)

I applied delta to the code earlier but the player still sometimes gets stuck in the bottem left corner, and sometimes it moves like it’s fine.
It can also make a few laps around the river, and then get stuck again.
image
how do I fix this?

Right now the only way I can think of solving this is adding walls around the conveyor belt and extending the collisions of the conveyor belt.

btw: (like almost everybody else asking questions, I’m a newbie and I will probably not reply fast at all(school) )
btw 2 the sequel: (I can provide a video to showcase the problem in greater detail if you want me to)

i assume your character is a physicsbody? You should put this code into “physics_process” and you should also you the “velocity” to set the speed and direction and then call “move_and_slide()” or “move_and_collide()”

1 Like

Thanks! all I need to do was move the movement function into a physics_process
and now it’s consistent! (:

I found info on why over here

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.