> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: Motion
icon: footprints
---

# <ApiPageIcon icon="footprints" />Motion

<ApiExposes data="[{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;motion.WalkTo.Options&#x22;,&#x22;h&#x22;:&#x22;#motionwalktooptions&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;motion.Status&#x22;,&#x22;h&#x22;:&#x22;#motionstatus&#x22;},{&#x22;k&#x22;:&#x22;NAMESPACE&#x22;,&#x22;c&#x22;:&#x22;fn&#x22;,&#x22;s&#x22;:&#x22;motion&#x22;,&#x22;h&#x22;:&#x22;#motion-1&#x22;}]" />

## motion.WalkTo.Options<ApiTag label="object type" />

Options for `motion.WalkTo`. All fields are optional. If `approach` or `stop` is not a value of
its enum, `motion.WalkTo` throws an error.

<ApiMembers>
  <ApiMember kind="prop" name="motion.WalkTo.Options.approach" summary="How the path toward the target is shaped. The default is `motion.ApproachMode.kArc`." ret="[[{&#x22;s&#x22;:&#x22;motion.ApproachMode&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/input/motion#motion-ApproachMode&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="motion.WalkTo.Options.nudge" summary="Allows small corrections near the target. The default is `true`." ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="motion.WalkTo.Options.stop" summary="How the point to start stopping is chosen. The default is `motion.StopMode.kClosest`." ret="[[{&#x22;s&#x22;:&#x22;motion.StopMode&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/input/motion#motion-StopMode&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="motion.WalkTo.Options.velocity" summary="The velocity that the player should have on arrival, in units per second. Use it to follow a moving target. The default is a zero vector." ret="[[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="motion.WalkTo.Options.walk" summary="Pass `true` to always walk, and `false` to always run. If it is nil, the walk key of the user is kept." ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />
</ApiMembers>

## motion.Status<ApiTag label="object type" />

The result of the last command that the planner planned. It is returned by `motion.Status`.

<ApiMembers>
  <ApiMember kind="prop" name="motion.Status.command_number" summary="The number of the command that this status was planned for." ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]" />

  <ApiMember kind="prop" name="motion.Status.distance" summary="The distance that is left to the target." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]]" />

  <ApiMember kind="prop" name="motion.Status.phase" summary="The current phase of the planner." ret="[[{&#x22;s&#x22;:&#x22;motion.Status.Phase&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/input/motion#motion-Status-Phase&#x22;}]]" />

  <ApiMember kind="prop" name="motion.Status.predicted_miss" summary="The predicted distance by which the player misses the target. It is nil when there is no prediction." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="motion.Status.speed" summary="The planned speed for the command." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]]" />

  <ApiMember kind="prop" name="motion.Status.ticks_to_rest" summary="The predicted number of ticks until the player stops. It is nil when there is no prediction." ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="type" name="motion.Status.Phase" summary="The phase of the movement planner, returned in `motion.Status`." ret="[[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}]]" expand="[{&#x22;n&#x22;:&#x22;&#x22;,&#x22;values&#x22;:[[&#x22;\&#x22;approach\&#x22;&#x22;,&#x22;&#x22;,&#x22;Moving toward the target position.&#x22;],[&#x22;\&#x22;solve\&#x22;&#x22;,&#x22;&#x22;,&#x22;Calculating where to start stopping.&#x22;],[&#x22;\&#x22;bleed\&#x22;&#x22;,&#x22;&#x22;,&#x22;Losing speed before the stop.&#x22;],[&#x22;\&#x22;track\&#x22;&#x22;,&#x22;&#x22;,&#x22;Following a moving target.&#x22;],[&#x22;\&#x22;nudge\&#x22;&#x22;,&#x22;&#x22;,&#x22;Making a last small correction.&#x22;],[&#x22;\&#x22;hold\&#x22;&#x22;,&#x22;&#x22;,&#x22;Staying at the target. The player also stays in place when a wall or another object stops a nudge from getting closer.&#x22;]]}]" />
</ApiMembers>

<Heading level={2} id="motion-1">
  motion

  <ApiTag label="global table" />
</Heading>

<ApiMembers>
  <ApiMember kind="fn" name="motion.WalkTo" summary="Asks the movement planner to walk the local player to `target`. The request is valid only for the command that is being built, so call this function in every `pre_movement` event." args="target, options?" sig="[{&#x22;s&#x22;:&#x22;motion.WalkTo&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;target&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;[, &#x22;},{&#x22;s&#x22;:&#x22;options&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;motion.WalkTo.Options&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/input/motion#motionwalktooptions&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;target&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The position to walk to.&#x22;},{&#x22;n&#x22;:&#x22;options&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;motion.WalkTo.Options&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/input/motion#motionwalktooptions&#x22;}],&#x22;d&#x22;:&#x22;Options for the planner.&#x22;,&#x22;o&#x22;:true}]">
    <ApiNotes>
      If `options` is not a table or nil, the function throws an error.
    </ApiNotes>
  </ApiMember>

  <ApiMember kind="fn" name="motion.Active" summary="Returns true if a `motion.WalkTo` request is active for the command that is being built." args="" sig="[{&#x22;s&#x22;:&#x22;motion.Active&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}]]" nodiscard />

  <ApiMember kind="fn" name="motion.Status" summary="Returns the result of the last command that the planner planned." args="" sig="[{&#x22;s&#x22;:&#x22;motion.Status&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;motion.Status&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/input/motion#motionstatus&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;motion.Status&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/input/motion#motionstatus&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" nodiscard>
    <ApiNotes>
      In the `pre_movement` event, this is the result of the previous command, because the current
      command is planned after the event returns. In the `post_movement` event, this is the result of
      the current command.

      Returns nil if the planner did not control the last command.
    </ApiNotes>
  </ApiMember>

  <ApiMember kind="type" name="motion.ApproachMode" summary="How `motion.WalkTo` shapes the path toward the target." ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]">
    <ApiEnum name="motion.ApproachMode" values="[[&#x22;kArc&#x22;,&#x22;0&#x22;,&#x22;Turns the current velocity onto the line through the target and keeps the speed.&#x22;],[&#x22;kStop&#x22;,&#x22;1&#x22;,&#x22;Stops completely when the direction is wrong, then speeds up straight toward the target.&#x22;]]" />
  </ApiMember>

  <ApiMember kind="type" name="motion.StopMode" summary="How `motion.WalkTo` chooses the point at which the player starts stopping." ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]">
    <ApiEnum name="motion.StopMode" values="[[&#x22;kClosest&#x22;,&#x22;0&#x22;,&#x22;The point after which the player is predicted to stop closest to the target.&#x22;],[&#x22;kSafest&#x22;,&#x22;1&#x22;,&#x22;The point after which the player is predicted to stop before the target. The player never stops past it.&#x22;]]" />
  </ApiMember>
</ApiMembers>
