Similar to creative_prop MoveTo disposed error when called from other Verse but with different causes.
I’ve been getting the dreaded run-time error:
[2023.05.02-04.37.50:700][ 33]LogVerse: Error: VerseRuntimeErrors: GetTransform called on disposed object. Use .IsDisposed[] to check before calling.
So I’ve bracketed my access of that Prop with:
if (Prop.IsValid[]):
(Quick side-note: please fix the error message, it took me a ridiculously long time to stop searching for IsDisposed in all the digests, and find the comment above GetTransform that gives the correct function name)
Unfortunately, once this fails, it fails forever - that Prop reference is never coming back in that function.
Even though the Prop is visible on the screen.
Even though a thread is actively controlling it and moving it around using the exact same variable in the same class.
The interesting part is that it only ever happens when I “Push Verse Changes”. It works perfectly if I “Push Changes”… unfortunately that takes over a minute to deploy and start where “Push Verse Changes” is about 10 seconds.
FYI here’s the code, LaunchPoint and AimPoint are the functions that fail if I update the Verse Changes alone. MoveTowards works perfectly all the time.
gun_manager := class(creative_device):
@editable PlayerManager : player_manager = player_manager {}
@editable Prop : creative_prop = creative_prop {}
var StartPos : vector3 = vector3{}
var DefaultRot : rotation = rotation {}
var DefaultYPR : [] float = array {}
var MyProp : creative_prop = creative_prop {}
OnBegin<override>()<suspends>:void=
#spawn{ TurnToFace() }
spawn{ MoveTowards() }
Print("GunManager is ready")
LaunchPoint():vector3=
if (Prop.IsValid[]):
PropTransform := Prop.GetTransform()
PropPosition := PropTransform.Translation
PropRotation := PropTransform.Rotation
OffsetPosition := PropPosition + PropRotation.RotateVector(vector3{ X:=50.0, Y:=00.0, Z:=20.0 })
return OffsetPosition
else:
Print("Can't get LaunchPoint yet")
return vector3{}
AimPoint():vector3=
if (Prop.IsValid[]):
PropTransform := Prop.GetTransform()
PropPosition := PropTransform.Translation
PropRotation := PropTransform.Rotation
OffsetPosition := PropPosition + PropRotation.RotateVector(vector3{ X:=5000.0, Y:=0.0, Z:=20.0 })
return OffsetPosition
else:
Print("Can't get AimPoint yet")
return vector3{}
MoveTowards()<suspends>:void=
Print("MoveTowards started")
loop:
if (Player := PlayerManager.GetCharacter[0]):
PropTransform := Prop.GetTransform()
PropPosition := PropTransform.Translation
PlayTransform := Player.GetTransform()
PlayPosition := PlayTransform.Translation
PlayRotation := PlayTransform.Rotation
OffsetPosition := PlayPosition + PlayRotation.RotateVector(vector3{ X:=0.0, Y:=70.0, Z:=60.0 })
# move smoothly
SpawnTask := spawn{ Prop.MoveTo(OffsetPosition, PlayRotation, 0.5) }
# block until move is complete
SpawnTask.Await()
Sleep(0.0)
The only difference is that MoveTowards is fired up from OnBegin, and the other two functions are called from a Weapon class with an object pool for the bullets.