bacteria.gd 479 B

123456789101112131415161718
  1. extends KinematicBody2D
  2. var motion = Vector2()
  3. var speed = 400
  4. var attackrange = 80
  5. func _physics_process(delta):
  6. move_and_slide(motion * speed)
  7. $hitbox.position = motion * attackrange
  8. $Icon.rotation = atan2(motion.y,motion.x)
  9. func _input(event):
  10. if event is InputEventScreenDrag or event is InputEventScreenTouch and event.is_pressed():
  11. # print(event.position)
  12. motion = (event.position - get_global_transform_with_canvas().origin).normalized()
  13. else:
  14. motion *= .8