# Prediction: stop() method

> The stop() method of the Prediction interface stops sampling and pushing inputs, so the client can start another prediction.

The **`stop()`** method of the [`Prediction`](/docs/client/prediction) interface stops sampling and pushing inputs and frees what the stepper keeps for the prediction world.

## Syntax

```ts
stop()
```

### Parameters

None.

### Return value

None (`undefined`).

### Exceptions

None.

## Description

A client runs one prediction at a time, since inputs are numbered per client: [`RoomClient.predict()`](/docs/client/room-client/predict) throws while another prediction on the client hasn't been stopped. To predict with a new stepper or `sample`, stop the old one first.

`stop()` calls the stepper's `release()`, if it has one, with the prediction world. Calling it again does nothing. After it, [`push()`](/docs/client/prediction/push) does nothing: the input isn't stepped or sent. A stopped prediction stays in [`RoomClient.predictions`](/docs/client/room-client/predictions), and still reconciles the inputs it sent.

A `sample` that throws stops the prediction as `stop()` does.

## Examples

### Switching from a runner to a car

When the player gets into a car, the game stops predicting the runner and predicts the car with the car's stepper.

```ts
// get-in.ts
import { defineSchema, defineStepper, entity, type Prediction, type RoomClient } from "@irtio/client";

const Car = entity("car", { driver: "string", speed: "f32" });
export const schema = defineSchema({ entities: [Car] });
const carStepper = defineStepper<{ throttle: number }>({
  step(world, inputs, dt) {
    for (const c of world.all(Car)) c.speed += (inputs.get(c.driver)?.throttle ?? 0) * 4 * dt;
  },
});

export function getIn(room: RoomClient, onFoot: Prediction<unknown>, throttle: () => number) {
  onFoot.stop();
  return room.predict(carStepper, {
    find: (r) => [...r.entities.all(Car)].find((c) => c.driver === r.player),
    sample: () => ({ throttle: throttle() }),
  });
}
```

## See also

- [`RoomClient.predict()`](/docs/client/room-client/predict)
- [`RoomClient.predictions`](/docs/client/room-client/predictions)
- [`defineStepper()`](/docs/room/definestepper), for `release()`
