wired movement without input

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

i have this code for my player

extends KinematicBody2D
var screen_size

# Declare member variables here. Examples:
# var a = 2
# var b = "text"

# Called when the node enters the scene tree for the first time.
func _ready():
	screen_size = get_viewport_rect().size
# Called every frame. 'delta' is the elapsed time since the previous frame.
# warning-ignore:unused_argument
func _process(delta):
	var volicty = Vector2()
	if Input.is_action_pressed("ui_right"):
		volicty.x += 1
	if Input.is_action_pressed("ui_left"):
		volicty.x -= 1
	if Input.is_action_pressed("ui_up"):
		volicty.y -= 1
	if Input.is_action_pressed("ui_down"):
		volicty.y += 1
	if volicty.length() > 0:
		volicty = volicty.normalized() * maindata.speed
		$body.play()
	else:
		$body.stop()
		
	position += volicty * delta
	position.x = clamp(position.x, 0, screen_size.x)
	position.y = clamp(position.y, 0, screen_size.y)
	volicty = move_and_slide(volicty)
	if volicty.y !=0:
		if volicty.y < 0:
			$body.animation = "up"
			$body.raise()
			$hands.animation = "back"
			
		else:
			$body.animation = "down"
			$hands.raise()
			$hands.animation = "front"
			

		
	elif volicty.x !=0:
		$body.animation = "left"
		$body.flip_h = volicty.x > 0

	
func _on_Timer_timeout():
	 $animaton.play("hands")
	 $Timer.start()
func _input(event):
	var zoom = Vector2()
	if Input.is_action_pressed("zoom_in") or Input.is_action_pressed("ui_accept"):
		zoom = $camera.get_zoom()
		zoom = Vector2(0.5,0.5) * zoom
		$camera.set_zoom(zoom)
	if Input.is_action_pressed("zoom_out"):
		zoom = $camera.get_zoom()
		zoom = Vector2(1.5,1.5) * zoom
		$camera.set_zoom(zoom)

and it always move by itself without any input any help ?
the something that confuse me a lot is that was working just well and and just broke
and i tried a lot of stuff and just didn’t work
and thanks in advance

:bust_in_silhouette: Reply From: kidscancode

You can’t do this with a KinematicBody2D:

position += volicty * delta

Kinematic bodies must be moved using their movement methods. Which should also be done in _physics_process().

I strongly recommend reading this:
Using KinematicBody2D
and this:
2D Movement Examples

i tried it with _physics_process() now and it didn’t work
by the way thank for fast answer
edit i tried deleting delta also

hero2002 | 2020-06-14 23:28

:bust_in_silhouette: Reply From: hero2002

I found the problem it because I was putting the main scane in autoload in project setting