# Move forward is jittering

Attention Topic was automatically imported from the old Question2Answer platform.

Hi

I have an object that use `move_toward` to follow the player. The movement works, but the object is jittering when the player moves as well (it moves fine when the player isn’t moving, but the object still needs to move to it’s wanted position).

the code:

``````func update_position(delta):
var p: Vector2 = entered_body.global_position
var c: Vector2 = self.global_position
var target: Vector2 = p + min_distance * p.direction_to(c)

if(entered_body.velocity.x < 0):
last_position = 35
elif(entered_body.velocity.x > 0):
last_position = -35
target.x += last_position
self.global_position = c.move_toward(target, (150 + abs(target.x - global_position.x) + abs(target.y - global_position.y)) * delta)
``````

Some explanations:

• `entered_body`is the body (Usually the player) that the object needs to follow
• `min_distance` is calculated by the amount of objects that need to follow the player. It starts as 0, and grow with the amount of objects that need to follow

Player movement code if needed:

``````velocity = Vector2(Input.get_action_strength("ui_right") -
Input.get_action_strength("ui_left"), velocity.y)

velocity.x = velocity.x * move_speed * speed_multiplayer
velocity.y += gravity * delta

animationManager(delta)

if(velocity.x != last_velocity.x and velocity.x != 0):
last_velocity.x = velocity.x

move_and_slide()
self.position.x = snapped(self.position.x, 1)
self.position.y = snapped(self.position.y, 1)
``````

example video:

Sprites info:
Player - 32X32
Floppy-disk - 18X18