0 votes

I tried different animation commands but none of them work. Idk what should i do.

extends KinematicBody2D

const MOVESPEED = 100
func _physics
process(delta):
var move_vec = Vector2()

if Input.is_action_pressed("ui_up"):
    move_vec.y -= 1
    add_animation(Player/AnimatedSprite.up)

elif Input.is_action_pressed("ui_down"):
    move_vec.y += 1


if Input.is_action_pressed("ui_left"):
    move_vec.x -= 1


elif Input.is_action_pressed("ui_right"):
    move_vec.x += 1



move_vec = move_vec.normalized()
move_and_collide(move_vec * MOVE_SPEED * delta)
in Engine by (163 points)

Have you tried the command $AnimatedSprite.play("up")?

Yes i did, but that didn't work as well...
Thanks for your suggestion tho!

I don't know if you have already solved it but I have been thinking more about your problem. Try making a separate function for animation like:

func player_animation():
var motion = Vector2()
if motion.y < 0:
$AnimatedSprite.play("up")

then place it inside your physicsprocess function:

func physicsprocess(delta):
player_animation()

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.