HomeModule plugins › AFM_Spawner
Module

AFM_Spawner

Spawns actors from definitions, with a replicated variant and a pickup dummy that hands a spawned object straight into the player's grip.

What it gives you

  • Data-driven spawning from spawn definitions
  • Replicated spawning through the player controller
  • Spawn-to-hand for VR pickup

Requires

AFM_AutoDestroy AFM_Visibility AFS_UI AFS_UX_Grip

Required by

AFE_Showroom AF_Examples

5 assets60 API members

Description

The spawner turns "give the player one of these" into configuration. BP_Spawner holds spawn definitions and produces actors on demand; BPC_PlayerController_ReplicatedSpawner routes spawning through the player controller so it works in multiplayer with correct ownership.

BP_Helper_Spawn_PickupDummy is the piece that makes it feel right in VR: it presents a preview the player can grab, and the real actor is spawned and handed to the grip at the moment of the grab, so there is no visible pop.

Setup

  1. Enable AFM_Spawner.
  2. Place a BP_Spawner and fill in its spawn definitions.
  3. For multiplayer, add BPC_PlayerController_ReplicatedSpawner to your player controller.

Usage

Spawning into the player's hand

Configure the spawner with a pickup dummy. The player grabs the preview and receives the real actor.

Tracking what was spawned

BPC_Helper_SpawnedActor is added to spawned actors so the spawner can find and manage them.

A freshly spawned object already in the player’s hand
AFM_Spawner_result.pngA freshly spawned object already in the player’s hand
A freshly spawned object already in the player’s hand

Key properties

PropertyWhen to change
Spawn definitionsWhat can be spawned and with what mesh preview
Spawner stateControls availability and cooldown

Extending

Derive from BP_Spawner for custom spawn rules; ST_SpawnDef describes each entry.

Multiplayer notes

Multiplayer

Use the replicated spawner component so spawning is authoritative and the resulting actor is owned by the requesting player.

Example map

Map_Examples_Spawner demonstrates spawn-to-hand and replicated spawning.

Troubleshooting

Spawned objects cannot be picked up by other players. Ownership was not set — use the replicated spawner rather than spawning directly.

API reference

Every blueprint asset in this plugin. Expand an asset to see its members.

Blueprints

BP_Spawner15 members
extends Actor · implements OutsidePawnRPCInterface
KindNameSignatureDescription
varSpawnClassDefinitionClass<Actor>Actor class each pickup dummy spawns when a hand grabs it, passed on as every dummy is created. Change it at runtime through Update Spawner so the dummy already in place is rebuilt with it.
varMeshRepresentationDefinitionST_Spawner_MeshStatic mesh and relative transform of the pickup dummy standing in for the spawnable actor. The transform places the dummy against the spawner; change mesh and class together through Update Spawner.
varSingleInstanceDefinitionboolWhether the replacement dummy stays an ungrabbable hologram until the actor last spawned is destroyed, rather than until the player lets go of it. Leave it off where one copy after another should be pulled from the spawner.
varDespawnTimerDefinitionfloatSeconds a spawned actor survives after the last hand lets go, applied through the helper component each dummy adds to the actor it spawns. Negative values keep the actor for good; use Update Despawn Timer to change it at runtime.
varReset ScaleDefinitionboolWhether a spawned actor takes only the dummy's world location, upright and at unit scale, rather than the dummy's whole world transform. Leave it on where the dummy is shrunk or turned to sit on a panel.
varSpawn SoundDefinitionSoundBaseSound played at the centre of each pickup dummy as it appears and again as it turns from hologram back into a solid object. Leave empty for a silent spawner.
fngetRepresentingMaterial(MaterialIndex: int, out DynamicMaterial: MaterialInstanceDynamic)Returns the dynamic material at the given slot of the current pickup dummy, for tinting or fading the object on offer. Returns nothing while no dummy exists.
eventSetSpawnerState(State: E_Spawner_State)Shows or hides the current pickup dummy through its visibility switch, or, for delete, removes the dummy and destroys the spawner with it. Delete does nothing at all while there is no dummy, so the spawner survives.
eventOnActorSpawned_Event(Actor: Actor, PickupComponent: BPC_Interaction_Grip_Pickup)Internal handler run once a dummy has spawned its actor: re-broadcasts the actor on On Actor Spawned, creates a fresh dummy as a hologram, and then waits either for the spawned actor to be destroyed or for it to be released, according to Single Instance, before that dummy is made solid.
eventCreatePickupDummy(Hologram: bool)Spawns a pickup dummy at the mesh representation's transform, attaches it to the spawner, hands it the class, timer, sound and hologram material, and broadcasts On Representing Mesh Spawned. Called at begin play with a solid dummy and after every spawn with a hologram one.
eventOnDestroyed_Event(DestroyedActor: Actor)Internal handler used while Single Instance is on, turning the waiting hologram back into a solid dummy once the actor that was spawned is destroyed.
eventOnGripped_Release_Event(SourceInfo: ST_SourceInfo)Internal handler used while Single Instance is off, turning the waiting hologram back into a solid dummy as soon as the player lets go of the actor they spawned.
eventOnDestroyed_Event_0(DestroyedActor: Actor)Internal handler bound to the spawner's own destruction, which clears the hologram on the current dummy so one that outlives its spawner is left solid.
eventUpdateSpawner(SpawnClass: Class<Actor>, MeshRepresentation: ST_Spawner_Mesh)Replaces the class and the mesh representation at runtime and passes both to the dummy in place, so the spawner offers a different object without being respawned.
eventUpdateDespawnTimer(DespawnTimer: float)Sets the despawn delay and pushes it straight to the dummy in place, so the next actor spawned uses the new value. Actors already spawned keep the timer they were given.

Components

BPC_PlayerController_ReplicatedSpawner7 members
extends ActorComponent · implements OutsidePawnRPCInterface
KindNameSignatureDescription
fnCheckSpawnBuffer_ClientSpawn Buffer()Reports every buffered spawn whose actor has now arrived on this client through On Actor Spawned, drops those entries and schedules another pass. Run from the buffer's replication notify; entries whose actor has yet to replicate in are caught by a later pass.
fnCheckSpawnBuffer_ServerSpawn Buffer()Prunes buffered spawns whose actor no longer exists and schedules another pass, so the buffer stops offering clients actors that have since been destroyed. Server-side counterpart to the client check.
eventServer_SpawnActor(const RequestID: Guid, Actor: Class<Actor>, SpawnTransform: Transform)Server RPC that spawns the requested class at the given transform and, when that class replicates, files it in the spawn buffer against the request ID so the asking client hears about it once it arrives. A class that does not replicate is spawned and never reported back.
eventSpawnAndReplicateActor(RequestID: Guid, Actor: Class<Actor>, SpawnTransform: Transform)Asks the server to spawn an actor for this player, tagging the request with an ID the caller matches when On Actor Spawned reports the result. Called on the owning client by the pickup dummy; bind to On Actor Spawned before calling it.
eventRemoveSpawnBufferIndexes(const BufferElementsToRemove: int[])Internal helper that drops the given entries from the unconfirmed spawns and rebuilds the replicated buffer from what is left. The values are the counters recorded with each spawn, not positions in the buffer.
eventRetriggerSpawnBuffer_Client()Waits a fiftieth of a second and runs the client buffer check again, giving actors still in flight time to replicate in. Internal to the buffer loop, which stops once the buffer is empty.
eventRetriggerSpawnBuffer_Server()Waits a fiftieth of a second and runs the server buffer check again, so entries are pruned as their actors go away. Internal to the buffer loop, which stops once the buffer is empty.

Helper

BPC_Helper_SpawnedActor4 members
extends ActorComponent
KindNameSignatureDescription
varDespawnTimerSettingsfloatSeconds between the last hand letting go of this actor and its deletion. Negative values switch despawning off; the count starts again on every release and is cancelled as soon as the actor is picked up.
eventOnActorPickup_Event(GrabCoordinator: BPC_PickupCoordinator)Internal handler that cancels the pending despawn when a hand takes hold of the owner, bound to the pickup coordinator at begin play.
eventOnActorReleased_Event(GrabCoordinator: BPC_PickupCoordinator)Internal handler that starts the despawn countdown once the last hand has let go, provided Despawn Timer is not negative.
eventDespawn()Deletes the owning actor once the countdown has run out, fading it out through its visibility component where it has one. Fired by the timer, but you can call it to remove a spawned actor early.
BP_Helper_Spawn_PickupDummy14 members
extends Actor
KindNameSignatureDescription
varRepresentationMeshContentST_Spawner_MeshStatic mesh and relative transform this dummy stands in for the spawnable actor with. The mesh is applied at begin play and again through Update Pickup Dummy; the transform is only re-applied to a dummy that has already been grabbed.
varActorToSpawnContentClass<Actor>Actor class spawned the moment a hand grabs this dummy. Whether the class replicates decides the route: replicating classes are requested from the player controller's replicated spawner, the rest are spawned on the grabbing machine only.
varDespawnTimerContentfloatSeconds after release before the spawned actor deletes itself, given to the helper component added to it as it is spawned. Negative values let the actor stay for good.
varHologramMaterialContentMaterialInterfaceMaterial every slot of the mesh is swapped to while the dummy is a hologram. The materials it had are stored and put back when the hologram is switched off, so leaving this empty leaves an invisible dummy in the way.
varResetScaleContentboolWhether the spawned actor takes only this dummy's world location, upright and at unit scale, rather than its whole world transform. Leave it on where the dummy is shrunk or turned to suit a panel and the real object should appear at its own size.
varSpawnSoundContentSoundBaseSound played at the centre of the dummy when it appears and again when it stops being a hologram. Leave empty for a silent dummy.
fngetMostAppropiateGripAbility(Actor: Actor, out GripComponent: BPC_Interaction_Grip_Pickup)Returns the first pickup grip interaction found on the given actor, which is the one the hand's grip is handed over to after spawning. Returns nothing when the actor cannot be picked up, and the spawn then goes unreported.
fngetSpawnTransform() → TransformReturns the transform the actor is spawned at: this dummy's world location with no rotation and unit scale while Reset Scale is set, otherwise the dummy's world transform as it stands.
fngetDummyMaterial(InMaterialIndex: int, out OutMaterialInstanceDynamic: MaterialInstanceDynamic)Returns a dynamic material for the given slot. While the dummy is a hologram it is the stored material the mesh reverts to once the hologram clears, created and cached on first request so tinting it does not disturb the hologram; otherwise it is the live material on the mesh.
eventOnGripped_Start(SourceInfo: ST_SourceInfo)Internal handler bound to the dummy's grip interaction that spawns the real actor as soon as a hand takes hold, and only on the machine of the pawn that grabbed. Replicating classes are requested through the player controller's replicated spawner, the rest are spawned there and then.
eventOnActorSpawned_Event(RequestID: Guid, SpawnedActor: Actor)Moves the newly spawned actor onto the spawn transform, adds the spawned actor helper carrying the despawn timer, and passes the hand's grip across to the actor's own pickup interaction so the player ends up holding the real thing. Requests whose ID is not this dummy's are ignored.
eventOnGripped_Release(SourceInfo: ST_SourceInfo)Internal handler bound to the grip interaction that fades the dummy out and destroys it once the hand lets go, which normally happens the instant the grip moves across to the spawned actor.
eventSetHologram(Set: bool)Turns the dummy into a hologram or back into a solid object, swapping every material for the hologram one and holding a blocker on its grip interaction while it is on. Switching it off restores the stored materials and plays Spawn Sound; asking for the state it is already in does nothing.
eventUpdatePickupDummy(RepresentationMesh: ST_Spawner_Mesh, ActorToSpawn: Class<Actor>)Swaps the mesh and the class this dummy offers at runtime, applying the new static mesh at once. The relative transform from the mesh definition is only re-applied to a dummy that has already been grabbed, so one still sitting on its spawner stays where it is.

Widgets

AFOverlay_Spawner20 members
extends ExtendedOverlay · implements BPI_WidgetElement
KindNameSignatureDescription
varSpawn ClassSettingsClass<Actor>Actor class handed to the spawner at the moment this element creates it. Editing it afterwards leaves an existing spawner untouched; go through Update Spawner on the spawner itself to change what is on offer at runtime.
varMesh RepresentationSettingsST_Spawner_MeshStatic mesh and relative transform of the pickup dummy that stands in for the spawnable actor, passed to the spawner as it is created. The transform positions the dummy against the spawner rather than against the panel.
varSingle InstanceSettingsboolWhether the next dummy stays an ungrabbable hologram until the actor last spawned is destroyed, rather than until it is released. Passed to the spawner when this element creates it.
varDespawn TimerSettingsfloatSeconds a spawned actor survives after the last hand lets go, handed to the spawner and on to every actor it produces. Negative values keep the actor indefinitely.
varRelativeDistanceFromWidgetSettings|LayoutfloatDistance in centimetres the spawner stands in front of the widget surface, used as the forward axis of its relative transform. Raise it to keep the offered object clear of the panel.
varAnchorOfWidgetSettings|LayoutVector2DAnchor on this element, in fractions of its own size, from which the spawner's position across the widget plane is measured. Leave at zero to measure from the top-left corner of the element.
varActiveStateboolWhether this element keeps a spawner alive at all. Switch it with Set Active rather than writing it directly, since clearing it deletes the spawner and its dummy and setting it starts the visibility loop again.
varSpawn SoundSettings|SoundSoundBaseSound played at the centre of each pickup dummy as it appears and again as it turns from hologram back into a solid object. Passed to the spawner on creation; leave empty for a silent spawner.
fngetRelativeTransform() → TransformReturns the transform the spawner is placed at, standing Relative Distance From Widget in front of the widget plane and lined up with this element's position across it. Rotation is zero and the relative scale is a hundred, which undoes the shrink a widget component applies so the object appears at world size.
fncanBeVisible(out Visible: E_Spawner_State)Returns whether the spawner should show, hide or be deleted. Showing needs the element to be active, laid out with a real size, the widget component visible, no switcher hiding it and no overlay open in front of it; an inactive or unlaid-out element asks for deletion instead of a hide.
fngetRepresentingMaterial(MaterialIndex: int, out DynamicMaterial: MaterialInstanceDynamic)Returns the dynamic material at the given slot of the spawner's current pickup dummy, so the panel can tint or fade the object it is offering. Returns nothing until the spawner has been created.
eventOnWidgetVisibilityChanged_Event_0()Internal handler bound to the widget component's own visibility change, which re-runs the visibility check so the spawner follows the panel it belongs to.
eventWidgetElement_Initiate(Parent: WBP_Base, ReplicationIndex: name)Stores the parent widget and its widget component, subscribes to the visibility, fade and overlay notifications it sends, then runs Set Active with the current setting. Called once by the parent widget after construction; a parent with no widget component leaves this element inert.
eventOnVisibilityChanged_Event(InVisibility: ESlateVisibility)Internal handler bound to the parent widget's visibility change, which re-runs the visibility check.
eventSetActive(Set: bool)Switches the element on or off and re-runs the visibility check. While on it keeps re-checking every 0.1 seconds, so the spawner tracks the panel; passing false runs one last check, which deletes the spawner along with its dummy.
eventCheckVisibility()Applies the result of Can Be Visible: creates the spawner on the first show and attaches it to the widget component, otherwise moves it back into place, or tells it to hide or delete itself. A deleted spawner is created afresh the next time showing is allowed.
eventOnOverlayOpened_Event()Internal handler bound to the widget component's overlay notification, which re-runs the visibility check so the spawner stands down while an overlay is open in front of the panel.
eventWidgetElement_SwitcherVisibility(Switcher: AFSwitcher, Set: bool)Records that a switcher is hiding this element, or clears that record again, and re-runs the visibility check. The spawner hides while any switcher is holding it back; the parent widget calls this as pages change, so there is no reason to call it yourself.
eventActorSpawned(Actor: Actor)Internal handler that forwards the spawner's notification of a spawned actor to On Actor Spawned on this element, so other widgets can bind here rather than to the spawner it owns.
eventOnRepresentingMeshSpawned_Event()Internal handler that forwards the spawner's notification of a new pickup dummy to On Representing Mesh Spawned on this element. Bind to it if the dummy's materials need restyling each time one appears.