Hey! I’ve been doing a lot of work trying to make an AI system where a bunch of AI props are spawned and moved around via Routines, and can be destroyed by the player. I’ve been able to get this functionality working somewhat, but issues eventually happen when scaled up/testing (with ~100 objects).
Consistently, GetTransform() throws issues during gameplay. I call it once every half tick of the AI (0.05 vs 0.1 Sleep in loop) to get the current position/rotation of objects for various functions that need them. I have been doing my best to make this as failsafe as possible.
This is my current setup to try and make it foolproof, though it’s still causing me issues. TriggerCancelEvent() is just a function that cancels the current “AI” routine that is happening concurrently (moving the objects around with MoveTo).
IsValidCheck()<suspends>:void=
loop:
Sleep(0.05)
if(Data.Prop.IsValid[]):
Print("Valid Letter Check Transform")
if(Position := FailableGetPosition[Data.Prop]):
set CurPosition = Position
else:
Print("FAILED POSITION")
if(Rotation := FailableGetRotation[Data.Prop]):
set CurRotation = Rotation
else:
Print("FAILED ROTATION")
else:
TriggerCancelEvent()
return
FailableGetPosition(Prop : creative_prop)<transacts><decides>:vector3=
var ReturnedVector :?vector3 = false
Transform := Data.Prop.GetTransform()
set ReturnedVector = option{Transform.Translation}
ReturnedVector?
FailableGetRotation(Prop : creative_prop)<transacts><decides>:rotation=
var ReturnedRotation :?rotation = false
Transform := Data.Prop.GetTransform()
set ReturnedRotation = option{Transform.Rotation}
ReturnedRotation?
Looking at this post (Link) it seems like the issue is with GetTransform() being called on a prop that’s set to “None” but is still considered valid? Is there a simple way to check this in addition to the IsValid check? Been losing my mind over this issue because the exception seems to get triggered so arbitrarily (will test the game and it works fine for days, then testing with others it suddenly happens immediately).