SpawnProp

method
SpawnProp<native><public>(

Spawns a `creative_prop` at the specified `Position` and `Rotation`. `Position` and `Rotation` units are in cm. The relative scale defined in the `creative_prop_asset` will be applied upon spawn. Returns tuple: 0: Instance of a `creative_prop`. False if no `creative_prop` could be created. See `spawn_prop_result` for failure cases. 1: Success or failure results.

Module
/Fortnite.com/Devices
Declared in
Devices
Source
fortnite

Used in

SpawnTransform := transform{
            Translation := Location,
            Rotation := IdentityRotation(),
            Scale := vector3{X := 1.0, Y := 1.0, Z := 1.0}
        }

        # SpawnProp stamps our prefab into the world at SpawnTransform.
        # It returns an option, so we unwrap it with `if`.
        # Note: SpawnProp is the real UEFN API for spawning prop assets
        # at runtime; full Entity/Instantiate APIs are not yet public.
        SpawnedProp := SpawnProp(TrapPrefab, SpawnTransform)
        # The prop is visible and collidable the moment it spawns.
        # If your asset has a trap_device component wired up in the
ProceduralBuilding / Spawner Device verse-source
var SpawnPropResult:tuple(?creative_prop, spawn_prop_result) = (false, spawn_prop_result.Ok)
                #profile("     DoSpawn"):
                    # Spawn the prop, continue if its good
                    set SpawnPropResult = SpawnProp(CreativeAsset, CurrentSpawnInfo.Transform)
                    
                SpawnResult := SpawnPropResult(1)

                if:
                    SpawnResult = spawn_prop_result.Ok                    
                    NewProp := SpawnPropResult(0)?
Lib / Mesh Grid verse-source
SpawnProp<public>(Piece:piece_type, Voxel:vector3i, Rotation:prop_yaw):void=
        var HeldTransform : held_transform = held_transform{}

        if:            
            Zone := BuildSystem?.BuildSite?
        then:
            
            HeldTransform.RotatePiece(Rotation)

            PieceSize := Piece.Size
            var HalfSize : vector3 = (PieceSize * 0.5)

            # We always store the mesh at its 'minimum' corner
            if:
                PieceSize.X <> PieceSize.Y # See if the build piece is not radially symmetrical 
                Rotation = prop_yaw.deg_90 or Rotation = prop_yaw.deg_270 # See if if piece is 90 degrees in either direction
            then:  # if it is, then we need to rotate the voxel size
                set HalfSize = MakeVector3(HalfSize.Y, HalfSize.X, HalfSize.Z) 
                    
            CursorCord:vector3 = Zone.ZoneOrigin + vector3:
                X := (Voxel.X * BuildGridSize.X) + (HalfSize.X * BuildGridSize.X)
                Y := (Voxel.Y * BuildGridSize.Y) + (HalfSize.Y * BuildGridSize.Y)
                Z := (Voxel.Z * BuildGridSize.Z) + (HalfSize.Z * BuildGridSize.Z)

            # Tell spawner device to create prop
            Zone.SpawnerDevice.CheckOut(
                Piece, 
                Voxel, 
                HeldTransform.ToTransform(CursorCord), 
                Rotation,
                Zone.BuildSystem)
Lib / Player Data verse-source
# Create cursor prop
        InitTM := transform:
            Scale:=vector3{X:=1.0, Y:=1.0, Z:=1.0}
            Rotation:=IdentityRotation()
            Translation:=vector3{X:=0.0, Y:=0.0, Z:=-10000.0}

        SpawnCursorResult := SpawnProp(RootDevice.BP_Cursor, InitTM)        
        if(NewProp := SpawnCursorResult(0)?):
            set FaceCursorProp = option{ NewProp }          

    # Called when player leaves site
    Removed<public>():void=
        HideCursor()
SpaceGrammar / Vo Wfc verse-source
then:
            # it's the prop we want, do nothing
            #Print("Existing mesh in place")
        else:
            # Clear existing prop and spawn a new one
            BuildSystem.MeshGrid.ClearPropForVoxel(Pos)                            
            BuildSystem.MeshGrid.SpawnProp(PropToSpawn, Pos, Rot)
            set BuildSystem.PropCount += 1

    SpawnPropsFromTiles(Box:voxel_box, BuildSystem:build_system):void=

        PropPrimes:tuple(int,int,int,int) := (37, 53, 61, 191)
        RotPrimes:tuple(int,int,int,int) := (37, 53, 61, 191)
SpaceGrammar / Vo Prop verse-source
MatchPropEntry[CurrentEntry, NewProp]
        then:
            # We match, no need to do anything
        else:
            # It's different, clear old prop and spawn new one
            BuildSystem.MeshGrid.ClearPropForVoxel(Voxel)
            BuildSystem.MeshGrid.SpawnProp(NewProp(0), Voxel, NewProp(1))
            set BuildSystem.PropCount += 1
         


    Operate<override>(Box:voxel_box, Rot:prop_yaw, BuildSystem:build_system):void=
        #Print("vo_prop.Operate {Box}")
SantaToyFactory / Candy Cane Field verse-source
ShowCandyCaneEffect(CandyCane:candy_cane)<suspends>:void=
        Transform := CandyCane.PropManipulator.GetTransform()
        Position := Transform.Translation
        Rotation := Transform.Rotation
        SpawnResult := SpawnProp(CandyCaneEffect, Position, Rotation)
        if (EffectProp := SpawnResult(0)?):
            Sleep(3.0)
            EffectProp.Dispose()
SantaToyFactory / Order verse-source
StartRotation := MakeRotationFromYawPitchRollDegrees(GetRandomFloat(-180.0, 180.0), GetRandomFloat(-5.0, 5.0), GetRandomFloat(-5.0, 5.0))

        # Play deliver audio.
        DeliverAudioPlayer.Play()

        if:
            Prop := SpawnProp(PropAsset, StartPosition, StartRotation)(0)?
        then:
            PropTransform := Prop.GetTransform()
            TargetPosition := SackInitialTransform.Translation + SackOffset
            TargetRotation := StartRotation.RotateBy(MakeRotationFromYawPitchRollDegrees(GetRandomFloat(-45.0, 45.0), GetRandomFloat(-30.0, 30.0), GetRandomFloat(-30.0, 30.0)))

            sync:
                block:
                    Prop.MoveTo(TargetPosition, TargetRotation, 0.3)
                    # Hide the prop before disposing it to avoid showing LEGO explosion effect.
                    Prop.Hide()
                    Prop.Dispose()
                block:
                    if:
                        TapPushedBackPosition := TapInitialTransform.Translation + TapPushedBackOffset
                        TapProp.TeleportTo[TapPushedBackPosition, TapInitialTransform.Rotation]
                    then:
                        TapProp.MoveTo(TapInitialTransform, 0.15)
                block:
                    Sleep(0.2)
                    if:
                        SackProp.TeleportTo[SackInitialTransform]
                    then:
                        SackProp.Shake(3.0, 5.0, 5, 0.3)
SantaToyFactory / Daily Gift verse-source
ShowGiftEffect()<suspends>:void=
        Transform := PropManipulator.GetTransform()
        Position := Transform.Translation
        Rotation := Transform.Rotation
        SpawnResult := SpawnProp(GiftEffect, Position, Rotation)
        if (EffectProp := SpawnResult(0)?):
            Sleep(3.0)
            EffectProp.Dispose()
Factory / Factory Element verse-source
ShowEffect(Effect:creative_prop_asset, EffectPositionProp:creative_prop)<suspends>:void=
        Transform := EffectPositionProp.GetTransform()
        SpawnResult := SpawnProp(Effect, Transform)
        if (EffectProp := SpawnResult(0)?):
            Sleep(3.0)
            EffectProp.Dispose()

    # Shows the build preview at the position of the prop.
    ShowBuildPreview(PreviewPositionProp:creative_prop):void=