Develop

Multi Spawn sample overview

Updated: May 7, 2026

Overview

This sample demonstrates how to spawn objects at different physical surfaces in a room using MR Utility Kit’s FindSpawnPositions API. The Multi Spawn sample is a shooting gallery game that places 19 targets across walls, floors, ceilings, furniture, and open space, showing developers how to build experiences that distribute content throughout a mixed reality environment.

What you will learn

  • Use FindSpawnPositions to spawn objects at different surface types (walls, floors, ceilings, furniture)
  • Filter spawn locations using SceneLabels to target specific surface types
  • Spawn floating objects in open space between surfaces
  • Respond to Scene API events (SceneLoadedEvent, RoomRemovedEvent) for dynamic content management
  • Implement surface-specific object behaviors (orientation, culling, animation)

Requirements

  • Meta Quest device with mixed reality capability
  • Unity development environment configured for Meta Quest development
  • Scene model created on your device. To set up your space, see the Meta Quest setup documentation.
For SDK version requirements and build configuration, see the sample README.

Get started

Clone or download the Unity MR Utility Kit Sample repository from GitHub. Open the project in Unity and load the FindMultiSpawn.unity scene. Build and deploy to your Meta Quest device using the build instructions in the README.

Explore the sample

The sample includes five spawner configurations that distribute targets across different surfaces in your room.
File / SceneWhat it demonstratesKey concepts
FindMultiSpawn.unity
Main scene with 5 spawner GameObjects and game HUD
Event-driven spawning, multi-surface placement
Scripts/MultiSpawnMenu.cs
Game state machine and timer controller
Coordinating multiple spawners, gameplay state transitions
Targets/Target.cs
Per-target type behavior and lifecycle
Surface-specific orientation, proximity culling, hidden target removal
Guns/Bullet/Bullet.cs
Projectile physics and collision handling
Raycasting, VFX triggering, UI interaction
Guns/Scripts/GunShot.cs
Player input and shooting mechanics
OVRInput integration, audio and visual feedback
Guns/VFX/MuzzleV2/MuzzleLight.cs
Muzzle flash lighting synchronization
Particle system integration

Runtime behavior

When you launch the sample, MRUK processes your room’s Scene API data and visualizes the room geometry using EffectMesh. Five FindSpawnPositions components then spawn 19 targets throughout your space — on walls, the floor, the ceiling, furniture surfaces, and floating in open air.
A HUD menu follows your headset with a START button and timer. Shooting the START button begins a timed round.
Each target you hit disappears with visual and audio feedback. Each miss spawns a “MISSED” label and adds a 0.5-second time penalty.
When all targets are cleared, the sample plays a victory sound and displays “NICE! PLAY AGAIN!” Shooting the button again resets the game.

Key concepts

Spawner configuration by surface type

The sample uses five FindSpawnPositions components, each configured to target a specific surface type through the SpawnLocations property and Labels bitmask:
Spawner GameObjectLabelsSurface typeTargets
MultiSpawn_Wall_RedTile
4 (WALL_FACE)
Walls
3
MultiSpawn_Floor_GreenTile
1 (FLOOR)
Floor
5
MultiSpawn_Ceiling_BlueTile
2 (CEILING)
Ceiling
5
MultiSpawn_Surface_LightGreenTile
8088
Furniture surfaces
3
MultiSpawn_Floating
-1 (all)
Open space
3
The wall spawner also sets SpawnLocations to VerticalSurfaces to constrain placement to vertical planes. See these GameObjects in FindMultiSpawn.unity.

Event-driven spawn coordination

The sample responds to MRUK’s SceneLoadedEvent to trigger spawning after room data is ready. MultiSpawnMenu.StartSpawningTargets() iterates through all FindSpawnPositions components and calls StartSpawn on each one:
foreach (var spawner in _findSpawnPositions)
{
    spawner.StartSpawn(MRUK.Instance.GetCurrentRoom());
}
Source: Scripts/MultiSpawnMenu.cs
When a room is removed, RoomRemovedEvent triggers ClearSpawnedPrefabs() on all spawners to clean up content. This pattern ensures content stays synchronized with Scene API updates.
For complete FindSpawnPositions API details, see the MR Utility Kit reference documentation.

Surface-specific target behavior

Each target type adjusts its behavior based on spawn location. Floor targets snap to the surface, orient toward the camera, and randomize their pedestal height. Ceiling targets orient upside-down relative to the ceiling surface. Floating targets oscillate using Perlin noise to create movement in open space. Wall targets snap to the wall plane and face outward. Surface targets snap to furniture and randomize their animation start time. See the TargetType enum and surface-specific setup methods in Targets/Target.cs.

Proximity and occlusion culling

The sample implements two culling strategies to improve player experience. After a 0.1-second delay, each target raycasts from the reticle position toward the camera; if the ray is obstructed, the target destroys itself to prevent impossible shots. Additionally, targets within 1 meter of the camera (_destroyIfCloserThan) are removed to maintain comfortable viewing distance. These checks run in Target.cs after spawning completes.

Extend the sample

  • Modify the SpawnAmount property on each FindSpawnPositions component to increase difficulty by spawning more targets per surface type.
  • Adjust the Labels bitmask on the furniture spawner to target specific furniture types (see MRUKAnchor.SceneLabels values).
  • Add new target prefabs with custom behaviors for different surface interactions, or implement power-ups that spawn at specific label locations.
For related spatial placement examples, see the other MR Utility Kit samples such as Floor Zone (unobstructed placement) and Virtual Home (prefab spawning on surfaces).