0 votes

my going up animation is not working and I have no idea about it
this is the code for the node the node that not play the going up animation:

extends KinematicBody2D

var speed : int = 400
var vol : Vector2 = Vector2()
onready var player = get_node(".")
onready var sprite = get_node("animations")

func _physics_process(delta):
vol.x = 0
vol.y = 0
if Input.is_action_pressed("go_right"):
    vol.x += speed
if Input.is_action_pressed("go_left"):
    vol.x -= speed
if Input.is_action_pressed("go_up"):
    vol.y -= speed
if Input.is_action_pressed("go_down"):
    vol.y += speed
vol = move_and_slide(vol, Vector2.UP)

if vol.x == 0:
    sprite.play("idle")
elif vol.x < 0:
    sprite.set_flip_h(true)
    sprite.play("walking")
elif vol.x > 0:
    sprite.set_flip_h(false)
    sprite.play("walking")
elif vol.y < 0:
    sprite.set_flip_h(false)
    sprite.play("walking")
elif vol.y > 0:
    sprite.set_flip_h(false)
    sprite.play("walking")

but my going left and right ones are working, only my going up and down is not working is not working

and you please solve this problem.

Godot version v3.2.3
in Engine by (12 points)

1 Answer

0 votes

You are using one animation for all those directions, the only difference is sprite flip. This means that whatever You press, whatever the direction, one and the same animation is playing.
What do You want to happen when pressing up ? How does Your "walking" animation look ? You know that You are only flipping sprite horizontally and not vertically, right ? If You want to flip it vertically use flip_v

by (5,252 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.