Attention | Topic was automatically imported from the old Question2Answer platform. | |
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