> For the complete documentation index, see [llms.txt](https://studio-docs.sandbox.game/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://studio-docs.sandbox.game/the-editor/how-to-spawn-the-player-and-place-npc-prefabs.md).

# How to spawn the player and place NPC prefabs

The **player** is not a character `.glb` you drag into the level. Play mode creates a **Pawn** at **Player Start** from the **GameMode**.

**NPCs** (guards, wildlife, other bodies in the world) are the opposite: you **place** prefab instances in the scene, or spawn them from code. They stay in the Outliner while you edit.

A Model Mesh Node that looks like a person is still scenery until it is a pawn tree (capsule, visual mesh, movement). See [How to use a character pawn](/the-editor/how-to-use-a-character-pawn.md) for that tree.

## Player vs NPC vs mesh

| What you want                          | What to put in the scene                        | What Play does                                         |
| -------------------------------------- | ----------------------------------------------- | ------------------------------------------------------ |
| The person you control                 | **Player Start** only                           | GameMode `pawnFactory` creates the pawn at that marker |
| Other characters standing in the level | Prefab instances (`prefabPath` on the instance) | Those copies are already there                         |
| A posed body with no gameplay          | A Model Mesh Node                               | Nothing. It does not walk                              |

{% hint style="info" %}
*NOTE: Do not place a player pawn (or the player prefab) in the scene **and** spawn from `pawnFactory`. You get two bodies. Keep the player prefab in `assets/prefabs/` and spawn it from GameMode.*
{% endhint %}

The Empty template does not set `pawnFactory`. Play then spawns a bare `ENGINE.Pawn`. Use a movement template (**3rd Person Movement**, **1st Person Movement**, and similar), or set `pawnFactory` yourself.

{% stepper %}
{% step %}

## Place Player Start on walkable ground

Select **Player Start** (`ENGINE.PlayerStart`) in the Outliner. Move it onto collision the pawn can stand on. Physics on that ground: [How to set collision and navmesh on mesh models](/the-editor/how-to-set-collision-and-navmesh-on-mesh-models.md).

Player Start is not a visible character.
{% endstep %}

{% step %}

## Set pawnFactory on GameMode

In your GameMode `initialize`, set `pawnFactory` to the pawn you want. Then run `pnpm build` and **Build Project** (`Ctrl+B` / `Cmd+B`). See [Project code fundamentals](/best-practices/project-code-fundamentals.md).

```typescript
public override initialize(options?: ENGINE.GameModeOptions): void {
  super.initialize({
    ...options,
    pawnFactory: async () => ENGINE.CharacterPawn.create(),
  });
}
```

Use `ENGINE.DefaultCharacterPawn.create()` when you need interact and fire. Details: [Doors, switches, pickups and triggers](/the-editor/doors-switches-pickups-and-triggers.md).

If you wrote a custom `@ENGINE.GameClass()` player, create that class in `pawnFactory` instead. A custom **PlayerController** is a separate factory (`playerControllerFactory`) on the same `initialize` options.
{% endstep %}

{% step %}

## Keep the player prefab out of the level

Templates often save the player as `.prefab.json` under `assets/prefabs/`. Configure the tree (capsule, `modelUrl` on the visual mesh, camera), then **Save as Prefab**.

Play still creates the player through `pawnFactory`. Dragging that prefab into the scene is a second copy. See [How to Set Up a Prefab](/the-editor/how-to-set-up-a-prefab.md).
{% endstep %}

{% step %}

## Place NPC prefabs in the scene

Build the NPC once (capsule, visual Model Mesh Node with physics off, animation if it needs it). **Save as Prefab**.

Drag the `.prefab.json` into the viewport for each copy. The instance shows `prefabPath` pointing at that file. Move each copy; do not duplicate by dragging a raw `.glb` if you need the full pawn tree.

Edit the shared template by double-clicking the prefab (Outliner or Assets). Placement on each instance stays on that instance.
{% endstep %}

{% step %}

## Or spawn NPCs from code

When they should appear at runtime, use `ENGINE.spawn` or `ENGINE.spawnAsync` with the fully qualified prefab path, then add the node to the world. Same APIs as on the prefab page.

```typescript
const npc = await ENGINE.spawnAsync(
  '@project/assets/prefabs/npc.prefab.json'
);
world.add(npc);
```

Do not patch `.genesys-scene` files to stamp characters. Place in the editor, or ask the agent through [Sandbox Studio MCP](/working-efficiently-with-ai/set-up-and-use-sandbox-studio-mcp.md).
{% endstep %}

{% step %}

## Enter Play mode and check the count

Play. You should control **one** pawn at Player Start. Placed NPC prefabs should still be in the world.

If you see two of “you,” a player pawn or player prefab is sitting in the scene. Remove it. If WASD does nothing, `pawnFactory` is still the bare Pawn, or Player Start is not on walkable collision.
{% endstep %}
{% endstepper %}

## Common mistakes

| What went wrong                              | What to do                                                              |
| -------------------------------------------- | ----------------------------------------------------------------------- |
| Dragged a character `.glb` and expected WASD | That is a Model Mesh Node. The player is a Pawn from GameMode.          |
| Player prefab sitting next to Player Start   | Remove the instance. Spawn from `pawnFactory` only.                     |
| NPCs are `.glb` props with physics on        | Save a pawn (or GameClass) as a prefab. Physics off on the visual mesh. |
| Empty project, Play, no walking character    | Set `pawnFactory`, or start from a movement template.                   |
| Two player bodies                            | Placed pawn **and** factory spawn. Keep only Player Start in the level. |

## What You've Done

You can leave the player to GameMode and Player Start, and put other characters in the world as prefab instances or `spawnAsync` calls. Next: [How to use a character pawn](/the-editor/how-to-use-a-character-pawn.md) to change the visual `.glb` and camera, or [Create an Animation State Machine](/the-editor/create-an-animation-state-machine.md) if an NPC needs its own graph.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://studio-docs.sandbox.game/the-editor/how-to-spawn-the-player-and-place-npc-prefabs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
