네트워크상의 플레이어 위치를 동기화하려고 할 때 이상한 결과가 나타납니다. 저는 두 명의 플레이어를 세계에 낳을 네트워크 게임을 가지고 있습니다. 각 플레이어는 관찰 된 대상이없는 네트워크보기를 가지고 있습니다. 각 고정 된 업데이트, 나는 서버에서 플레이어의 위치를 업데이트하기 위해 RPC 호출을합니다. 그러나 플레이어를 오른쪽으로 움직이면 위치가 업데이트되기 시작합니다. 플레이어를 오른쪽으로 움직이기 전까지는 다른 움직임이 표시되지 않습니다.이 경우 플레이어의 위치는 즉시 업데이트됩니다. 지금까지 관련 코드가 있습니다 :이상한 결과 네트워크상의 플레이어 위치 동기화
void FixedUpdate()
{
if (networkView.isMine)
{
grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
anim.SetBool("ground", grounded);
anim.SetFloat("vSpeed", rigidbody2D.velocity.y);
float move = Input.GetAxis("Horizontal");
anim.SetFloat("speed", Mathf.Abs(move));
rigidbody2D.velocity = new Vector2(move * MaxSpeed, rigidbody2D.velocity.y);
float speed = move * MaxSpeed;
networkView.RPC("UpdateNetworkPosition", RPCMode.Others, LastPosition, speed);
}
}
[RPC]
void UpdateNetworkPosition(Vector3 newPosition, float speed)
{
Debug.Log("Updating network position");
transform.position = Vector3.Lerp(transform.position, newPosition, Time.deltaTime * speed);
}
어떤 조언 주셔서 감사합니다!