I Creating prop bouncing motions for 2D games
The bouncing movement is implemented by finely changing the MoveTo value, but depending on the time, it may not be smooth, and in the case of multiple objects, it may not be smooth.
Anyone knows why this is happening and how to avoid it?
code:
Start()<suspends> : void =
set jumpForce = GetRandomFloat(JumpForceMin, JumpForceMax)
set currentForce = vector2{ X := GetRandomFloat(InitForceXMin, InitForceXMax), Y := 0.0}
loop:
UpdateMove()
UpdateMove()<suspends> : void =
set currentForce = vector2{X:= currentForce.X, Y:= currentForce.Y + Gravity}
toPos:vector3 = AddVector(GetTransform().Translation, currentForce)
MoveResult := MoveTo(toPos, GetTransform().Rotation, 0.2)
if (MoveResult = move_to_result.DestinationReached):
OnMoveEnd()
OnMoveEnd()<suspends> : void =
tran := GetTransform()
if(tran.Translation.Y >= FieldH):
initPos:= vector3{ X := tran.Translation.X, Y := FieldH - 1.0, Z:= tran.Translation.Z}
set currentForce = vector2{ X := currentForce.X, Y := -jumpForce}