private void PreparePlayerObject() { Player player = this; ControllableObject script = player.controllingObject.GetComponent <ControllableObject> (); if (script != null) { script.playerOwnerGameObject = player.gameObject; script.playerOwner = player; } }
/// This removes player control over object, but doesn't destroy it. public void RemoveAuthorityObjectForPlayer() { if (this.m_authorityObject != null) { ControllableObject ncp = this.m_authorityObject.GetComponent <ControllableObject> (); if (ncp != null) { ncp.playerOwnerGameObject = null; ncp.playerOwner = null; } this.m_authorityObject = null; } }
// public void RemovePlayerObject() { // } public void AssignAuthorityObjectForPlayer(GameObject go) { Player player = this; this.RemoveAuthorityObjectForPlayer(); ControllableObject ncp = go.GetComponent <ControllableObject> (); if (ncp != null) { ncp.playerOwnerGameObject = null; ncp.playerOwner = null; } player.m_authorityObject = go; if (ncp != null) { ncp.playerOwnerGameObject = player.gameObject; ncp.playerOwner = player; } NetworkServer.ReplacePlayerForConnection(player.conn, go, 1); }
public static bool IsInputting(this NetworkBehaviour networkBehaviour) { // if (networkBehaviour.isLocalPlayer) // we can't check only this, because netControl may be null // return true; if (!networkBehaviour.isLocalPlayer) // commands can not be sent if isLocalPlayer is not true { return(false); } ControllableObject ncp = networkBehaviour.GetComponent <ControllableObject> (); if (null == ncp) { return(false); } if (null == ncp.playerOwner) { return(false); } return(ncp.playerOwner == Player.local); }