Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class ServerMoveScript : MonoBehaviour {
- public Transform _Rotate_X_1;
- public Transform _Rotate_Z_1;
- public Transform _Rotate_X_2;
- public Transform _Rotate_Z_2;
- public Transform _Rotate_X_3;
- public Transform _Rotate_Z_3;
- public Transform _Rotate_X_4;
- public Transform _Rotate_Z_4;
- public int PlayerIs = 0;
- public int PlayerIsRt = 0;
- void Update()
- {
- switch (PlayerIs)
- {
- case 0:
- networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_1.rotation, _Rotate_Z_1.rotation, PlayerIs, PlayerIsRt, false);
- break;
- case 1:
- networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_2.rotation, _Rotate_Z_2.rotation, PlayerIs, PlayerIsRt, false);
- break;
- case 2:
- networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_3.rotation, _Rotate_Z_3.rotation, PlayerIs, PlayerIsRt, false);
- break;
- case 3:
- networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_4.rotation, _Rotate_Z_4.rotation, PlayerIs, PlayerIsRt, false);
- break;
- }
- }
- [RPC]
- private void _Rotate(Quaternion x, Quaternion z, int RotateInt, int RotateIntRt, bool RotateOn = false)
- {
- if(!RotateOn){
- if (Network.peerType == NetworkPeerType.Server)
- {
- switch (RotateInt){
- case 0:
- _Rotate_X_1.rotation = x;
- _Rotate_Z_1.rotation = z;
- break;
- case 1:
- _Rotate_X_2.rotation = x;
- _Rotate_Z_2.rotation = z;
- break;
- case 2:
- _Rotate_X_3.rotation = x;
- _Rotate_Z_3.rotation = z;
- break;
- case 3:
- _Rotate_X_4.rotation = x;
- _Rotate_Z_4.rotation = z;
- break;
- }
- switch (RotateInt)
- {
- case 0:
- networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_1.rotation, _Rotate_Z_1.rotation, RotateInt, RotateIntRt, true);
- break;
- case 1:
- networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_2.rotation, _Rotate_Z_2.rotation, RotateInt, RotateIntRt, true);
- break;
- case 2:
- networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_3.rotation, _Rotate_Z_3.rotation, RotateInt, RotateIntRt, true);
- break;
- case 3:
- networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_4.rotation, _Rotate_Z_4.rotation, RotateInt, RotateIntRt, true);
- break;
- }
- }
- if (Network.peerType == NetworkPeerType.Client)
- {
- switch (RotateInt)
- {
- case 0:
- _Rotate_X_1.rotation = x;
- _Rotate_Z_1.rotation = z;
- break;
- case 1:
- _Rotate_X_2.rotation = x;
- _Rotate_Z_2.rotation = z;
- break;
- case 2:
- _Rotate_X_3.rotation = x;
- _Rotate_Z_3.rotation = z;
- break;
- case 3:
- _Rotate_X_4.rotation = x;
- _Rotate_Z_4.rotation = z;
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment