Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2024
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. func get_input():
  2. input.x = int(Input.is_action_pressed("ui_right")) - int(Input.is_action_pressed("ui_left"))
  3. input.y = int(Input.is_action_pressed("ui_down")) - int(Input.is_action_pressed("ui_up"))
  4.  
  5. #Changes the animation playing on the player based on movement
  6. func handle_movement_animation():
  7. animated_sprite.flip_h=false
  8. if input.y >0:
  9. animated_sprite.play("walkdown")
  10. elif input.y <0:
  11. animated_sprite.play("walkup")
  12. elif input.x >0:
  13. #Walk Right
  14. animated_sprite.play("walkside")
  15. elif input.x <0:
  16. #Walk Left
  17. animated_sprite.flip_h=true
  18. animated_sprite.play("walkside")
  19. else:
  20. animated_sprite.play("idle")
  21.  
  22.  
  23. func _physics_process(delta):
  24. get_input()
  25. velocity = input*SPEED
  26. handle_movement_animation()
  27. move_and_slide()
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement