What I’m attempting to do is move a prop to a random location and then use an attached prop mover to move it straight down. This works as expected for the first instance, but each iteration after the prop will move to a new location correctly, but then move back to its original location instead of moving straight down. I’ve tried many things to get this to work correctly, but nothing has worked. There’s something I’m missing. Any help would be appreciated.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation/Tags }
using { /Verse.org/Random }
# A Verse-authored creative device that can be placed in a level
move_object_drop := class(creative_device):
@editable var PropBlock : []creative_prop = array{}
@editable var PropMover : []prop_mover_device = array{}
BlockDim : float = 384.0 # Block dimensions = 384
TargDist : float = 26.88 # BlockDim * 7 / 100
var GridCoords : [][][]int = array{}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
CreateGridCoords()
loop:
for (Index := 0..PropBlock.Length-1):
spawn { MoveProp(Index,RandomRotation(),RandomPosition()) }
Sleep(7.0)
MoveProp<private>(Index : int, Rotation : rotation, Position : vector3)<suspends> : void=
# if (PropMoverSet := PropMover[Index]):
# PropMoverSet.Reset()
if (PropBlockSet := PropBlock[Index]):
if (PropBlockSet.TeleportTo[Position, Rotation]) { }
Print("PropBlock moved")
Sleep(0.1)
if (PropMoverSet := PropMover[Index]):
PropMoverSet.Begin()
CreateGridCoords() : void =
GridSize : int = 9 # This should always be an odd number
if (Offset : int = Floor[(GridSize-1)*0.5]*-1):
Print("Offset = {Offset}")
set GridCoords =
for (Row := 0..GridSize-1):
for (Col := 0..GridSize-1):
array{Offset+Row,Offset+Col,0}
if (Xset : int = GridCoords[1][1][0]):
Print("I think this worked {Xset}")
RandomPosition() : vector3 =
XSet : float = GetRandomInt(-3,3)*BlockDim
YSet : float = GetRandomInt(-3,3)*BlockDim
ZSet : float = TargDist*100+(BlockDim/2.0)
Position : vector3 = vector3 {X:= XSet, Y:= YSet, Z:= ZSet}
Print("Position: {XSet}, {YSet}, {ZSet}")
return Position
RandomRotation() : rotation =
YawSet : float = GetRandomInt(0,1)*90.0
PitchSet : float = GetRandomInt(0,1)*90.0 # if (PitchSet < 90.0):
Rotation : rotation = MakeRotationFromYawPitchRollDegrees(YawSet,PitchSet,0.0)
Print("Pitch: {PitchSet} Yaw: {YawSet}")
return Rotation