troll.gd 430 B

12345678910111213
  1. extends KinematicBody2D
  2. const MOTION_SPEED = 160 # Pixels/second.
  3. func _physics_process(_delta):
  4. var motion = Vector2()
  5. motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
  6. motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
  7. motion.y /= 2
  8. motion = motion.normalized() * MOTION_SPEED
  9. #warning-ignore:return_value_discarded
  10. move_and_slide(motion)