Random big gap

Prompt please, I use a code from examples.
As the speed of the character's movement increases periodically, very distant coordinates arrive at the PlayerCommand.postion, because of this the character twitches.
In the screenshot below is an example of such a jump. The blue mark indicates the local position. And I can not find where I'm locally moving the client to this position.

public void SetState(Vector3 position, Vector3 velocity, bool isGrounded, int jumpFrames)
{
// assign new state
_stateInfo.position = position;
_stateInfo.velocity = velocity;
_stateInfo.jumpFrames = jumpFrames;
_stateInfo.isGrounded = isGrounded;
// assign local position
Debug.DrawRay(transform.localPosition, Vector3.up * 2, Color.blue, 10f);
Debug.DrawRay(_stateInfo.position, Vector3.up * 1, Color.red, 10f);
Debug.DrawLine(transform.localPosition + Vector3.up, _stateInfo.position + Vector3.up, Color.green, 10f);
transform.localPosition = _stateInfo.position;
}

Comments

Sign In or Register to comment.