Skip to main content

Spawning the Player

When building a scenario, you need to define which avatar the participant controls, which camera system is used, and which user interface appears on screen.

The most direct method is to place each element manually. Locate the controllable pawn, camera rig, and UI prefabs in the Project window, drag them into the scene, position them at the intended start point, and configure each as needed. This gives full control over the setup but is time-consuming when building multiple scenarios.

The Player Selector component simplifies this process by spawning all three elements automatically based on its configuration.

Player Selector​

Player Selector Inspector

The Player Selector component spawns the participant's controllable pawn, camera rig, and UI overlay at the start of a session based on its configuration.

Player Selector in Mountain View Hierarchy

In the Mountain View Scene Template, the Player Selector is attached to the same GameObject as the Game Mode (the GameMode GameObject). It has no dependency on Game Mode and can be placed on any GameObject in the scene.

info

A scene should contain only one Player Selector.

Setting the Start Point​

Starting Point tag

At the start of a session, the Player Selector locates the first GameObject in the scene tagged with StartPosition and uses it as the spawn point. The participant spawns at that GameObject's position and orientation.

Any GameObject in the scene can carry the StartPosition tag. If multiple GameObjects share this tag, the selector uses the first one it finds, which may differ between runs. To ensure consistent results, assign the tag to only one GameObject per scene. If no GameObject is tagged, the selector defaults to the world origin (0, 0, 0).

Starting Point Gizmo

The blue Z arrow on the Starting Point GameObject marks the direction the participant will face at spawn. Rotate the GameObject to set the intended facing direction.

Spawn Configuration​

The Player Selector spawns three categories of elements: a Controllable Pawn, a Camera Rig, and a User Interface Preset. Each category has:

  • A toggle (Spawn Controllable, Spawn Camera, or Spawn UI) that controls whether that category is spawned automatically at session start. The field is hidden while the toggle is off.
  • A field where you assign the prefab or scene to use when the toggle is enabled.

Disabling a toggle for a category means the Player Selector will not spawn that element. You can then place it manually in the scene.

The following tabs describe each category in detail.

A Controllable Pawn is the avatar the participant operates during a scenario. Each pawn includes its own model, input handling, physics, and configuration.

The project already includes several controllables, shown below. You can use them directly or extend them with your own.

Choosing a Controllable​

The Controllable Prefab field defines which pawn the Player Selector spawns. Click the object picker icon in the field to open the picker, a pop-up window filtered to show only prefabs with the Asset Label Controllable. The built-in controllables are the EgoAgent_* prefabs in Assets/mobisim/Actors/Vehicle/Prefabs and Assets/mobisim/Actors/Pedestrian/Prefabs.

Controllable Object Picker

note

The first time you open the object picker in a session, it may take a moment to load as Unity prepares the search results and previews. Subsequent opens are faster.

Making a Prefab Controllable​

To make a custom pawn prefab appear in the picker:

1
Select the pawn prefab

In the Project window, select the pawn prefab.

2
Open the Label tag

In the Inspector window, click the Label tag icon at the bottom right.

Label icon in Inspector

3
Select the controllable label

Select the label Controllable.

Controllable label selected

The prefab now appears as an option in the Controllable Pawn picker.

tip

Create multiple controllable prefab variants (for example, the same vehicle with different parameters) and switch between them in the Controllable Prefab field when testing scenarios.