Example on how to Spawn and Destroy Props using Verse

There is now the ability to spawn and destroy props at runtime using Verse! Here is a quick example of a script spawning a prop, waiting 1 second, then destroying the prop:

using { /Fortnite.com/Devices }
using { /Verse.org/Native }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /EpicGames.com/Temporary/Diagnostics }
using { /EpicGames.com/Temporary/SpatialMath }

log_prop_spawner_device := class(log_channel){}

prop_spawner_device := class(creative_device):
    Logger:log = log{Channel:=log_prop_spawner_device}

    # Reference to a single creative_prop_asset
    @editable
    var ChairProp:creative_prop_asset := DefaultCreativePropAsset

    # Reference to a creative_prop_asset array
    @editable
    var ChairProps:[]creative_prop_asset := array{}

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        Sleep (3.0)
        SpawnChairProps()

    # Spawn and destroy chair props
    SpawnChairProps()<suspends>:void=
        SpawnPosition:vector3 := vector3{X:=0.0, Y:=-700.0, Z:= 0.0}
        
        for ( Prop : ChairProps):
            SpawnedProp := SpawnProp(Prop, SpawnPosition, IdentityRotation())
            Sleep(1.0)
            if (CreativeProp := SpawnedProp(0)?):
                CreativeProp.Dispose()

16 Likes

This is so useful! Thanks for sharing!

The code is so clean and effective. There’s a lot of power here.

Oh wow this is awesome! :open_mouth: :heart_eyes: I’ve been looking forward to this feature for a while, thanks for adding it! Does this work with custom Building Props made with imported or modeled assets, or is it only for Fortnite props at the moment?

Also would you be willing to add this script to the Snippets library? I think people would appreciate finding it there.

I’ve been waiting for this! Nice :slight_smile:

For now it only works with Fortnite props.

There’s a Snippets library? Please point me to it.

OMG! Thanks for this!

2 Likes

No problem! It’s still new so there’s not much there but I hope to see more snippets soon! This reminds me I have to update my Day/Night Cycle snippet. I wrote it before Verse supported the Skydome Device so I had written a bunch of comments in it being like “pretend you can use the Skydome Device”. :laughing: I want to add more snippets when I get a chance.

1 Like

Thx for that, but is it also possible to spawn creative_prop objects?
I got a blueprint that i need multiple times. :slight_smile:

Yes, you can spawn up to 100 (Maybe now 300/500/1000) per creative_device using the same prop asset, or different ones. Just using the same code as posted above

That great but why only creative_prop_asset ?
I don’t get why there’s such limits on basic functionality on all other classes …

My guess is they haven’t figured out how to manage the automated island memory limit test with dynamically instanced UEFN devices (yet (hopefully)).

hmm you might be right , as it does run on their servers and you can’t test for that in stress test before publishing atm

Thank you for this example! I wasn’t finding very good resources on how to manage an array with creative_prop and this got be going. Much appreciated!