Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func get_input():
- input.x = int(Input.is_action_pressed("ui_right")) - int(Input.is_action_pressed("ui_left"))
- input.y = int(Input.is_action_pressed("ui_down")) - int(Input.is_action_pressed("ui_up"))
- #Changes the animation playing on the player based on movement
- func handle_movement_animation():
- animated_sprite.flip_h=false
- if input.y >0:
- animated_sprite.play("walkdown")
- elif input.y <0:
- animated_sprite.play("walkup")
- elif input.x >0:
- #Walk Right
- animated_sprite.play("walkside")
- elif input.x <0:
- #Walk Left
- animated_sprite.flip_h=true
- animated_sprite.play("walkside")
- else:
- animated_sprite.play("idle")
- func _physics_process(delta):
- get_input()
- velocity = input*SPEED
- handle_movement_animation()
- move_and_slide()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement