walking and idle animations

This commit is contained in:
chimchooree
2023-09-08 10:43:27 -05:00
parent 83faf15858
commit 50a478fd5c
4 changed files with 29 additions and 7 deletions
+6 -1
View File
@@ -41,15 +41,19 @@ func movement_key_pressed(direction):
if direction == 1: # right
velocity_sum.x = 0
velocity_sum.x += 1
get_user().animate("WalkRight")
elif direction == 2: # left
velocity_sum.x = 0
velocity_sum.x -= 1
get_user().animate("WalkLeft")
elif direction == 3: # up
velocity_sum.y = 0
velocity_sum.y -= 1
get_user().animate("WalkUp")
elif direction == 4: # down
velocity_sum.y = 0
velocity_sum.y += 1
get_user().animate("WalkDown")
# Velocity cannot be faster with more vectors
get_user().set_internal_velocity(velocity_sum)
@@ -58,9 +62,10 @@ func movement_key_released(direction):
velocity_sum.x = 0
elif direction == 3 or direction == 4: # up/down
velocity_sum.y = 0
get_user().animate("Idle")
get_user().set_internal_velocity(velocity_sum)
# Physics Process
func _physics_process(delta):
func _physics_process(_delta):
## Keyboard Movement
get_input()