extends RigidBody2D var reset_state := false var target_vector := Vector2.ZERO var collision_buffer: Array func _integrate_forces(state: PhysicsDirectBodyState2D) -> void: if reset_state: reset_state = false state.transform = Transform2D(0.0, target_vector) for idx in state.get_contact_count(): var body := state.get_contact_collider_object(idx) if body.is_in_group("bumper"): body.animate_bump() apply_central_impulse( state.get_contact_local_normal(idx) * body.get_impulse() ) if not collision_buffer.has(body): collision_buffer.append(body) get_tree().current_scene.get_node("HUD").score += 50 if state.get_contact_count() == 0: collision_buffer.clear() func move_body(target_position: Vector2) -> void: target_vector = target_position reset_state = true