Hi, looking for advice since most likely I just didn’t understand how Verse works, despite I’m reading the docs already for weeks. I spawn props in a grid of 2x2x2 or 3x3x3 let’s say, just a simple 3D array of props, a grid. The spawn works correctly, that’s the weird part, but referencing these existing props inside the array is impossible, it shows that all items of the array are empty except the first one (or the last one? I think the first one, yeah, the 1,1,1 item exists, and nothing else, in the array - but all the props are spawned correctly! how is it possible?)
Here is the code:
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }
my_log_channel := class(log_channel){}
my_device := class(creative_device):
# Create an instance of the `log` object.
Logger:log = log{ Channel := my_log_channel }
MyMethod()<transacts>:void =
# Printing to the log will work in <transacts> and <varies> contexts
Logger.Print("Something happened")
# A Verse-authored creative device that can be placed in a level
island_spawner := class(creative_device):
Logger:log = log{ Channel := my_log_channel }
GridLength : int = 2
GridDepth : int = 2
GridWidth : int = 2
var Counter : int = 0
var IslandsGrid : [][][]?creative_prop = array{array{array{}}}
@editable var FlyingIsland : creative_prop_asset = DefaultCreativePropAsset
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Print("init ok")
PositionIslands()
Print("Counter {Counter}")
Print("IslandsGrid.Length {IslandsGrid.Length}")
spawn:
MoveIslands(IslandsGrid)
PositionIslands():void=
set IslandsGrid =
for (Row := 1..GridWidth):
for (Column := 1..GridLength):
for (Layer := 1..GridDepth):
CreateIsland(Row, Column, Layer)
CreateIsland(Xpos : int, Ypos : int, Zpos : int) : ?creative_prop=
set Counter += 1
PositionX := float(Xpos * 800.0)
PositionY := float(Ypos * 800.0)
PositionZ := float(Zpos * 600.0) - 500.0
SpawnedCreativeProp := SpawnProp(FlyingIsland, vector3{X := PositionX, Y := PositionY, Z := PositionZ}, IdentityRotation())(0)
if (GotAProp := creative_prop[SpawnedCreativeProp?]):
Logger.Print("{Counter} prop spawned at: {PositionX} {PositionY} {PositionZ}")
return SpawnedCreativeProp
else:
Logger.Print("{Counter} failed to spawn at: {PositionX} {PositionY} {PositionZ}")
return false
MoveIslands( Islands : [][][]?creative_prop)<suspends> : void =
loop:
for (Row := 1..GridWidth):
for (Column := 1..GridLength):
for (Layer := 1..GridDepth):
if (Island := Islands[Row][Column][Layer]?):
Print("Moving Island: {Row} {Column} {Layer}")
T := Island.GetTransform()
var IslandPosition : vector3 := T.Translation
var IslandRotation : rotation := T.Rotation
#set IslandPosition.X += 1.0
set IslandPosition.Z -= 1.0
Island.MoveTo(IslandPosition, IslandRotation.ApplyYaw(0.10), 0.10)
else:
Print("NO Island at: {Row} {Column} {Layer}")
Sleep(0.5)
so the “Islands[Row][Column][Layer]” iteration after props were already created in the PositionIslands function, reveals that only 1 prop exists in the array, why? where’s the other props, they got spawned correctly but ended up not being added to the array? please suggest the optimal way to initialize that array of props in order to control them later? (position, rotation, I need to control from the array, moving these props in various ways during the game).
Thanks in advance