2016-09-11 7 views
0

플레이어에있는이 코드는 메뉴의 버튼 누름에 반응하며 처음에는 오렌지색으로 바뀌었을 때 "btn_MenuKill"버튼을 누르고 다음 번에 색을 바꿀 때 나타납니다 SyncVar Hook "void ProcessKillObject (bool _MP_Orange) {"에서 원래의 노란색으로 "print ("FIRE THE PROCESS ")를 수행하십시오. 에디터에서명령이 클라이언트에서 트리거되지 않음

시작 호스트

1) 호스트 클라이언트 (편집기 버튼을 클릭) = [명령]

2 일) 버튼을 클릭 여기에

상황/문제 remote-client = 작동하지 않는다. [Command]

생성 된 "원격"클라이언트에서 호스트 시작

1) 호스트 클라이언트에서 버튼을 클릭 = [명령] 원격 클라이언트에서 버튼을 클릭)

2 일 = [명령]에서 [명령] 때 작동하지 않는 이유를 이해가 안

작동 호스트가 편집기에 있고 리모컨의 버튼을 사용합니다. 여기

코드입니다 :

[SyncVar(hook = "ProcessKillObject")] public bool MP_KillOrange = false; 
[SyncVar(hook = "MoveMainMenu")] public bool MP_MainMenu; 
private NetworkIdentity objNetId; 
private Color32 yellowButtonColor = new Color32 (200, 200, 2, 255); 
private Color32 orangeButtonColor = new Color32 (255, 96, 0, 255); 

public void Btn_Kill() { 

    if (!isLocalPlayer) 
     return; 

    foreach (string objectTag in MP_Singleton.Instance.master_Object_List) { 
     GameObject dummy = GameObject.Find (objectTag); 
     Cmd_LocalAuthority (true, dummy); 
    } 

    Cmd_ProcessKill(); 
} 

// SyncVar Hook 
void ProcessKillObject(bool _MP_Orange) { 

    if (_MP_Orange) { 
     GameObject.Find ("btn_MenuKill").GetComponent<Button>().image.color = orangeButtonColor; 
    } else if (!_MP_Orange) { 
     GameObject.Find ("btn_MenuKill").GetComponent<Button>().image.color = yellowButtonColor; 

     print ("FIRE THE PROCESS"); 
    } 
} 

[Command] //>>>>>> THIS IS NOT TRIGGERED 
void Cmd_ProcessKill() { 

    // >>>>>>>>>>>>>>>>>>>>>> 
    GameObject.Find ("MyText").GetComponent<Text>().text = "HIT"; // TO SEE THAT THE COMMAD TRIGGER 
    //>>>>>>>>>>>>>>>>>>>>>>> 
    if (MP_KillOrange) 
     MP_MainMenu = !MP_MainMenu; 

    MP_KillOrange = !MP_KillOrange; 

} 


[Command] 
void Cmd_LocalAuthority(bool getAuthority, GameObject obj) { 

    objNetId = obj.GetComponent<NetworkIdentity>();  // get the object's network ID 

    if (getAuthority) { 
     objNetId.AssignClientAuthority (connectionToClient); // assign authority to the player 
    } else { 
     objNetId.RemoveClientAuthority (connectionToClient); // remove the authority from the player 
    } 
} 
+0

"Cmd_LocalAuthority (true, dummy);" 그것은 작동하지만, 내가 움직이는 플레이어가 아닌 오브젝트는 움직이는 곳에 머 무르지 않습니다. – PeterK

+0

해결 된, 나는 RPC를 사용하고 그때 그것은 효과가있다. – PeterK

답변

0

내가 RPC를 추가 한 후 작동합니다.

[ClientRpc] 
void Rpc_Position(GameObject myGO, float ranX, float ranY, int zDepth, float twist) { 

    myGO.transform.position = new Vector3 (ranX, ranY, zDepth); 
    myGO.transform.localEulerAngles = new Vector3(0f, 0f, twist); 

}