base_box.gd 346 B

12345678910
  1. extends CharacterBody2D
  2. class_name BaseBox
  3. func _input(event):
  4. if event is InputEventMouseButton and event.pressed:
  5. var player = get_node("../Player")
  6. if player.get_child(0).get_rect().has_point(to_local(event.position)):
  7. set_deferred("global_position", player.global_position)
  8. player.set_deferred("global_position", global_position)