예제 #1
0
 void FixedUpdate()
 {
     // I have no control over these pieces so retrieve network position and rotation
     // Need to add offset for other side of the board
     if (!PhotonView.IsMine)
     {
         transform.position = Vector3.MoveTowards(
             Rb.position,
             MyFlippedCoordinates.FlipPerspectiveOfBoardPiece(NetworkPositionRb, Board),
             Distance * (1.0f / PhotonNetwork.SerializationRate));
         Rb.isKinematic = NetworkIsKinematic;
         Rb.rotation    = NetworkRotation.normalized;
     }
 }
예제 #2
0
    void OnEvent(EventData photonEvent)
    {
        if (photonEvent.Code == (byte)RaiseEventCodes.PlayerSpawnEventCode)
        {
            object[] data = (object[])photonEvent.CustomData;

            Vector3    receivedPosition     = (Vector3)data[0];
            Quaternion receivedRotation     = (Quaternion)data[1];
            int        receivedViewID       = (int)data[2];
            bool       receievedFirstPlayer = (bool)data[3];

            GameObject player = receievedFirstPlayer
                                ? Instantiate(YellowPlayer,
                                              MyFlippedCoordinates.FlipPerspectiveOfBoardPiece(receivedPosition, Board), receivedRotation)
                                : Instantiate(RedPlayer,
                                              MyFlippedCoordinates.FlipPerspectiveOfBoardPiece(receivedPosition, Board), receivedRotation);

            PhotonView view = player.GetComponent <PhotonView>();
            view.ViewID = receivedViewID;
        }
    }