2017-04-16 7 views
1

입력 할 수있는 우주선이있는 멀티 플레이어 게임을 만들고 있습니다. 멀티 플레이어에 광자를 사용하고 있습니다.멀티 플레이어 강체 이동이 동기화되지 않음 (Photon)

아래 이미지에서 볼 수 있듯이 나는 PhotonView 우주선의 Rigidbody, Transform 및 Player와 동일합니다.
my PhotonView Settings

그러나 내가 배에 입장 할 때 다른 플레이어의 시야가 극도로 뒤떨어져 보입니다 (내가 정상적으로 배를 밀어 내면). 문제를 나타내는 video입니다.

플레이어가 고정 조인트를 사용하여 선박에 연결되었습니다. 나는 당신의 플레이어가 물리 객체를 결합하면, 그것은 완전히 장악한다, 모든이 기술을 권하고 싶지 않다

void Update() 
{ 
    //Raycast to check for ship 
    if ((Physics.Raycast(look, out hit, 9f) && hit.collider.tag == "Ship") 
    { 
     //set variables 
     shipObj = hit.collider.gameObject.transform.parent.gameObject; 
     ship = shipObj.GetComponent<SmallShipController>(); 

     if (Input.GetKeyDown(KeyCode.R)) 
     { 
      //check if ship is driven 
      if (!ship.driven) 
      { 
       driving = true; 
       ship.ChangeDriven(); 
       transform.position = ship.driverSeat.transform.position; 
       transform.rotation = ship.driverSeat.transform.rotation; 
       playersCamera.transform.position = ship.thirdPersonPosition.position; 
       playersCamera.transform.rotation = ship.thirdPersonPosition.rotation; 
       rb.detectCollisions = false; 
       rb.mass = 0; 
       rb.drag = 0; 
       rb.angularDrag = 0; 
       photonView.RPC("SetJoint", PhotonTargets.AllBuffered, shipObj.GetPhotonView().viewID); 
      } 
     } 
     if (driving) 
     { 
      if (Input.GetKey(KeyCode.A)) 
      { 
       ship.rb.AddRelativeForce(Vector3.left * ship.moveSpeed * Time.deltaTime); 
      } 
      if (Input.GetKey(KeyCode.W)) 
      { 
       ship.rb.AddRelativeForce(Vector3.forward * ship.moveSpeed * Time.deltaTime); 
      } 
      if (Input.GetKey(KeyCode.D)) 
      { 
       ship.rb.AddRelativeForce(Vector3.right * ship.moveSpeed * Time.deltaTime); 
      } 
      if (Input.GetKey(KeyCode.S)) 
      { 
       ship.rb.AddRelativeForce(Vector3.back * ship.moveSpeed * Time.deltaTime); 
      } 
      if (Input.GetKey(KeyCode.Space)) 
      { 
       ship.rb.AddRelativeForce(Vector3.up * ship.moveSpeed * Time.deltaTime * 0.5f); 
      } 
      if (Input.GetKey(KeyCode.LeftShift)) 
      { 
       ship.rb.AddRelativeForce(Vector3.down * ship.moveSpeed * Time.deltaTime * 0.5f); 
      } 
      if (Input.GetKey(KeyCode.Q)) 
      { 
       ship.rb.AddRelativeTorque(new Vector3(0, 0, Time.deltaTime * ship.moveSpeed)); 
      } 
      if (Input.GetKey(KeyCode.E)) 
      { 
       ship.rb.AddRelativeTorque(new Vector3(0, 0, Time.deltaTime * -ship.moveSpeed)); 
      } 
      if (Input.GetAxisRaw("Mouse Y") > 0.5f || Input.GetAxisRaw("Mouse Y") < 0.5f || Input.GetAxisRaw("Mouse X") > 0.5f || Input.GetAxisRaw("Mouse X") < 0.5f) 
      { 
       ship.rb.AddRelativeTorque(new Vector3(-Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0) * Time.deltaTime * ship.rotationSpeed); 
      } 
      if (Input.GetKey(KeyCode.C)) 
      { 
       ship.rb.velocity = ship.rb.velocity * 0.99f; 
       ship.rb.angularVelocity = ship.rb.angularVelocity * 0.99f; 
      } 
     } 
    } 
} 

[PunRPC] 
void SetJoint(int shipView) 
{ 
    shipObj = PhotonView.Find(shipView).gameObject; 
    shipObj.GetComponent<FixedJoint>().connectedBody = rb; 
} 

답변

0

:
여기 내 단축 코드입니다. 배를 소유주가 변경 될 수있는 장면 객체로 만들고, 플레이어가이 플레이어를 입력하려고 할 때이 플레이어를 해당 배의 소유자로 만듭니다. 그리고 onwership 관리에 의존하고 다양한 플레이어의 우주선을 안전하게 제어 할 수 있습니다.

또한 Photon 포럼을 사용하면 더 많은 회신을받을 수 있습니다.

안녕,

관련 문제