How can i add animation to my player?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Drawsi

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

extends KinematicBody2D

const MOVE_SPEED = 100
func _physics_process(delta):
var move_vec = Vector2()

if Input.is_action_pressed("ui_up"):
    move_vec.y -= 1

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)

Have you tried the command $“up”)?

Atomic Potato | 2019-04-23 21:21

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

Drawsi | 2019-04-24 17:40

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:

then place it inside your _physics_process function:

func _physics_process(delta):

Atomic Potato | 2019-04-27 17:16