Я работаю над игрой, и по какой-то причине, когда я пытаюсь вызвать функцию hit_check (), она не будет анимировать спрайт. все остальные анимации работали отлично, поэтому я запутался. Вот мой сценарий:
extends KinematicBody2D
var motion = Vector2(0,0)
const SPEED = 130
const GRAVITY = 15
const UP = Vector2(0,-1)
const JUMP_SPEED = 350
func _physics_process(delta):
apply_gravity()
hit_check()
jump_check()
move_check()
move_and_slide(motion, UP)
func apply_gravity():
if not is_on_floor():
motion.y += GRAVITY
else:
motion.y = 0
func jump_check():
if Input.is_action_pressed("jump") and is_on_floor():
motion.y -= JUMP_SPEED
func move_check():
if Input.is_action_pressed('left'):
$PlayerAnimation.flip_h = true
$PlayerAnimation.play("walk")
motion.x = -SPEED
elif Input.is_action_pressed('right'):
$PlayerAnimation.flip_h = false
$PlayerAnimation.play("walk")
motion.x = SPEED
else:
motion.x = 0
$PlayerAnimation.play("idle")
func hit_check():
if Input.is_action_pressed("hit"):
$PlayerAnimation.play("hit")
print
вhit_check()
перед анимацией. - person Mike67   schedule 12.10.2020