Hey! I’ve been using MoveTo to move some props around, and have been noticing some buggy behavior. It seems like the exact details of what was happening to me was described + said to have been fixed in this thread: Thread
The specific issue is I have a function that rotates a prop away from a player, and then makes it run away from them in a straight line. When it reaches the end of running away from the player, sometimes it will be warped back to where it started running for a split second. I don’t know what in particular is causing this - I’ve been setting up my code so only one MoveTo is triggering at a time, and I’m waiting for it to complete before doing any other movement. Has anyone else been noticing this issue, and is there something I can do/something I’m missing to guarantee this flickering doesn’t occur?
This is the function, it is a smaller part of a larger AI loop that runs suspends functions based on the state the object is in. The issue happens regardless of whether the Distance check succeeds or fails. CurPosition is set in a synced function every 0.05 seconds, and seems to consistently be getting the updated position of the prop.
Run()<suspends>:void=
Print("Begin Loop")
loop:
if(Data.Prop.IsValid[]):
Prop := Data.Prop
if(TargetPlayer := Data.TargetPlayer?):
Print("If player")
var PlayerTransform : transform = TargetPlayer.GetTransform()
var PlayerPosition : vector3 = PlayerTransform.Translation
NewRotation := GetLookAtRotation(PlayerPosition,CurPosition)
if(Prop.IsValid[]):
Prop.MoveTo(CurPosition,NewRotation,0.01)
MoveTime := Data.AIValues.RunDistance/Data.AIValues.RunSpeed
DirectionVector := NewRotation.GetLocalRight() * Data.AIValues.RunDistance
HalfWidth := (SpawnWidth / 2.0)
HalfDepth := (SpawnDepth / 2.0)
FinalFleeX := Clamp(CurPosition.X+DirectionVector.X,-HalfWidth + SpawnRoot.X,HalfWidth + SpawnRoot.X)
FinalFleeY := Clamp(CurPosition.Y+DirectionVector.Y,-HalfDepth + SpawnRoot.Y,HalfDepth + SpawnRoot.Y)
var FleeGoalPosition : vector3 = vector3{X:=FinalFleeX,Y:=FinalFleeY,Z:=CurPosition.Z}
if(Prop.IsValid[]):
Print("Begin Run Move Race")
Prop.MoveTo(FleeGoalPosition,NewRotation,MoveTime)
Print("Move TO Completed")
Print("Run Race Over")
if(TargetPlayer.IsActive[]):
set PlayerTransform = TargetPlayer.GetTransform()
set PlayerPosition = PlayerTransform.Translation
if(Distance(PlayerPosition,CurPosition) >= Data.AIValues.MinDistFromPlayer):
Print("Far Enough Away")
Idle()
break
else:
Print("Continue the run loop")
Print("End of Run Loop")