Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

👥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 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

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.

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.

1

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.

Player Start is not a visible character.

2

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.

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.

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.

3

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.

4

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.

5

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.

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.

6

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.

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 to change the visual .glb and camera, or Create an Animation State Machine if an NPC needs its own graph.

Last updated

Was this helpful?