Advertisement
CodeTortoise

Godot 2D Char Movement

Nov 5th, 2015
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. func process_movement(delta):
  2. var motion = Vector2(0,0)
  3.  
  4. if Input.is_action_pressed("move_up"):
  5. motion += Vector2(0, -1)
  6. set_rot(0)
  7. #print("up")
  8. if Input.is_action_pressed("move_down"):
  9. motion += Vector2(0, 1)
  10. set_rot(180)
  11. #print("down")
  12. if Input.is_action_pressed("move_right"):
  13. motion += Vector2(1, 0)
  14. set_rot(-90)
  15. #print("right")
  16. if Input.is_action_pressed("move_left"):
  17. motion += Vector2(-1, 0)
  18. set_rot(90)
  19. #print("left")
  20.  
  21. motion = motion.normalized() * speed * delta
  22.  
  23. move(motion)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement