# Spawn a configured food station from a BPVerse build spot

- **Status:** current.
- **Engine:** ue6-main `61e2877e`, Linux x86_64, Epic clang 23.1.5 (v27 SDK).
- **Context:** Standalone UE6, BPVerse actor in project Content, Python-authored map, Linux Development package.
- **Prerequisites:** [C++ actor and BPVerse bridge](/docs/recipes/bpverse-actor-in-headless-editor/), [game-instance subsystem reflection](/docs/recipes/bpverse-game-instance-subsystem/), and a native station that initializes in `BeginPlay`.

## Symptom

A data-authored build spot needs to spawn another generated Verse actor with the station kind, mesh and approach radius supplied by the map. Coop Zero's station reads its kind to choose capacity and initial portions in `BeginPlay`. Assigning the kind after an ordinary gameplay spawn would be too late for that initialization. This ordering constraint follows from the station and engine source.

## Smallest example / reproduction

Coop Zero's `Data/slice_layout.json` defines `BuildSpot` with `BuildName=Feeder2` and target class `/Game/_Verse.feed_refill_station`. The editor commandlet loads the class into a native `TSubclassOf<AActor>` property and saves the instance fields on the placed Verse spot. The station setup supplies the food kind, body, cap, fill and approach radius. `Config/DefaultGame.ini` supplies `BuildPrices=(Id=FirstBuildCost,Coins=24)`.

In the Verse `Interact` override, resolve the game state from the optional pawn, compare `GetCoins()` with the spot's price, and call `State.TryBuild(option{Self}, Who)` on acceptance. That native method validates the transaction, then calls the spot's spawn method.

## Solution

Use `FActorSpawnParameters` with `bDeferConstruction = true` and `Name = BuildName` when spawning the target through `UWorld::SpawnActor`. Use a name mode such as `Required_ErrorAndReturnNull` when map-defined IDs have to be stable and duplicates must fail. On the returned actor, set the native station fields and component transforms, then call `FinishSpawning` with the final transform. Check the returned actor before committing the build spot's state. If spawning fails, restore any reserved balance. Name the generated Verse target class differently from the instance names.

## Why it works

Deferring construction gives the caller access to the native components before gameplay initialization. The station's `BeginPlay` sees the authored kind and configured fill transform, so it initializes six food portions from the existing rules. The resulting instance enters the normal C++ care search and retains the generated Verse refill override. The map holds direct class and mesh references for the cook.

## Verified

- **Evidence level:** runs in editor.
- **How:** Ran Coop Zero's `UnrealEditor-Cmd` Python placement in NullRHI through the lane wrapper. The saved map reloaded with `SLICE_BUILD_SPOT actor=BuildSpot builds=Feeder2 price=24 class=/Game/_Verse.feed_refill_station`. The headless editor game logged `BUILD_REJECTED coins=16`, `STATION_READY station=Feeder2 portions=6 capacity=8 fill=0.75`, and `BUILD_OK coins=0 spot=BuildSpot target=Feeder2`.
- **Evidence level:** runs in packaged build. After Linux Development BuildCookRun, `bash Scripts/prove_build_spot.sh` ran the offscreen package. The log showed `VERSE_BUILD_OK`, `FEEDER_REFILLED feeder=8 added=2` after interaction at Feeder2, and `EAT hen=Poppy hunger=74 feeder=7 t=1097.60 ration=1 station=Feeder2`.
- **Date / by:** 2026-11-25, Coop Zero Step 09.

## Limits and assumptions

The verified target uses native components configured before construction. Classes with construction scripts that replace those components need their own initialization contract. IDs are unique within the slice map. The example uses a local single-player jar and a Development console fixture.
