walking and idle animations
This commit is contained in:
+6
-1
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user