I am trying to import 2 creative prop assets, transform them into props and then swap them out every 5 seconds inside an array of []?creative_prop
type.
I empty out array of creative prop type every loop, but for some reason the prop does not get swapped and instead both of them remain in the game:
Game_Manager := class(creative_device):
var Props : []?creative_prop = array{}
@editable Prop_asset_1 : creative_prop_asset = DefaultCreativePropAsset
@editable Prop_asset_2 : creative_prop_asset = DefaultCreativePropAsset
@editable var Prop_location : vector3 = vector3{}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
AppearProp()
AppearProp()<suspends>: void =
var UsingFirstAsset: logic = true # Boolean flag to track which asset is currently in use
loop:
set Props = array{}
# Conditional structure to alternate between Prop_asset_1 and Prop_asset_2
if (UsingFirstAsset = true):
NewProp := CreateProp(Prop_asset_1)
if (NewProp?):
set UsingFirstAsset = false # Switch to the next asset for the next iteration
set Props += array{NewProp}
else:
NewProp := CreateProp(Prop_asset_2)
if (NewProp?):
set UsingFirstAsset = true # Switch back to the first asset for the next iteration
set Props += array{NewProp}
Sleep(5.0)
CreateProp(Current_prop_asset : creative_prop_asset): ?creative_prop =
Created_prop_stuff := SpawnProp(Current_prop_asset, Prop_location, IdentityRotation())
Created_prop_itself := Created_prop_stuff(0)
Created_prop_type := Created_prop_stuff(1)
if (Created_prop_type = spawn_prop_result.Ok):
return Created_prop_itself
else:
return false
Changing set Props += array{NewProp}
to set Props = array{NewProp}
seems to have no effect either
I thought using set Props = array{}
would fix this issue since this should empty the prop array, but I am not achieving the expected result.