Hello, I'm stuck with a dumb issue. I just want to move my KinematicBody2D with an animation tree, everything works except that the body waits for the release of the button to move. I mean, if I hold the press on the button, the body doesn't move.
I have to stop pressing it so that the body moves, and it only moves a few pixels around. I used a script that works perfectly in other projects, I don't understand why it doesn't work on this specific project. Here is the code:
! ! extends KinematicBody2D
!
! var velocity = Vector2.ZERO
! onready var animTree = $AnimationTree
! onready var animState = animTree.get("parameters/playback")
! onready var animPlayer = $AnimationPlayer
! const ACCELERATION = 200
! const MAX_SPEED = 80
! const FRICTION = 500
!
! func _ready():
! animTree.active = true
! animState.start("Idle")
!
! func _physics_process(delta):
! var Input_vec = Vector2.ZERO
! Input_vec.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
! Input_vec.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
! Input_vec = Input_vec.normalized()
!
! if Input_vec != Vector2.ZERO:
! animTree.set("parameters/Idle/blend_position", Input_vec)
! animTree.set("parameters/Walk/blend_position", Input_vec)
! velocity = velocity.move_toward(Input_vec * MAX_SPEED, ACCELERATION * delta)
! else:
! animState.travel("Idle")
! velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
! move_and_slide(velocity)
!