MoveTo still causing some flickering issues

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")

@StewartTTG Thank you for your report! Can you please re-post using the “New Issue” option on the Issues and Bug Reporting forums? Posts with this feature are connected directly into our development team so we can quickly get to them!For more information, such as how to get the reference ID, please check out the article here: https://create.fortnite.com/news/using-the-creative-and-uefn-bug-reporting-form

Hey, so you’re right, this method is still not working very good for repetitive movements but I think your code can be improved.

So first of all, you’re calling a MoveTo of 0.01s, which acts as your only loop suspending method right now. But you cannot sleep 0.01s, the minimum is 0.033s (servers are running at 30fps)

I’m not sure about this, but I’m guessing it hard. So your movement will be done in 0.01s then the next loop will only occur 0.023s later, duration for which your prop won’t move.

I’m not sure if the next loop iteration happens on the same frame and replaces your previous MoveTo call (same frame) or if it waits 0.023s as I said. But anyway, try to increase this value to 0.0333s and see what happens.

Ok, that’s good to know! Before when I first was noticing/debugging the issue, that initial MoveTo was done in 0.5 seconds, I reduced it down to way shorter due to some other things i was working through. I tested it now with 0.033, 0.05, and 0.5 again, and the issue still occurred (though maybe a little less frequently? Could just be imagining that).

Yes because I didn’t tell you everything, you need to spawn{} the MoveTo and call a Sleep that’s way faster (let’s say (MoveTo duration - 0.1)), then you’ll have something acceptable :man_shrugging:

This way when your loop calls the next MoveTo, the old one is not finished yet and it gives something smoother!

1 Like

Oh, gotcha. Yeah, it does look smoother now!

1 Like