> For the complete documentation index, see [llms.txt](https://fehdead.gitbook.io/npc-kit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/dir.md).

# npc.dir

```lua
npc.dir(heading)
```

|                         |                                    |
| ----------------------- | ---------------------------------- |
| id                      | `0x0024`                           |
| arguments               | 1: Float                           |
| in NPC Kit              | yes                                |
| measured from a kit NPC | returns                            |
| vanilla scripts         | 12716 calls in 614 of 1114 scripts |

## What it does

Turns the NPC to face a heading, at once. It is a turn of zero frames: the same body as `rturnt_4b``(heading, frames)` with `frames = 0`.

## Arguments

### `heading` (Float)

The heading in radians. Heading `h` faces the direction `(sin h, cos h)` on the map's `(x, z)`: `0` faces +z, `1.5708` +x, `3.1416` -z, `-1.5708` -x. Any value works; the game wraps it. Vanilla's most common: `0` (992 calls), `1.5708`, `3.1416`, `4.7124`.

## Timing

Returns at once; the NPC faces the heading on the next frame.

## In NPC Kit

* In `init`, after `setpos2`: the NPC's starting heading.
* In a talk, on another NPC: `npc.on("id").dir(1.5708)`.
* The heading from one point to another, computed in Lua when `npc.add` runs: `math.atan(to[1] - from[1], to[3] - from[3])` (`references/staging.md`, Positions and headings).

## Used with

* [setpos2](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/setpos2.md) before it in `init`.
* [aturn\_261](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/aturn_261.md) + [turnsync](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/turnsync.md): the same heading, turned visibly.
* [aturn](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/aturn.md): face a point instead of a heading.

## Example

```lua
npc.setpos2(29.36, -9.0, 68.65);
npc.dir(1.676);
```

## Pitfalls

* In view of the player it snaps. For a turn the player sees, use `aturn_261(h)` and `turnsync()`.
