I’d really like to use Cmd and Rpc functions, even without an active connection, to simplify single player & multiplayer code.
Please? :3
I’d really like to use Cmd and Rpc functions, even without an active connection, to simplify single player & multiplayer code.
Please? :3
That’s similar to my question here I just asked: What is the correct way to begin an offline session? - Unity Engine - Unity Discussions
So if you are correct, it means they’re expecting us to host a dummy server. If so, then how is this done for single player sessions?
The way I’m currently doing things is similar to:
public void AssignNetworkAuthority() {
NetworkIdentity currentPlayer = Globals.playerTransform.GetComponent<NetworkIdentity>();
if (currentPlayer == null) {
//Debug.Log ("No player spawned yet, or playing locally.");
} else {
CmdAssignNetworkAuthority(currentPlayer.netId);
}
}
[Command] protected void CmdAssignNetworkAuthority(NetworkInstanceId toId) {
// other stuff
}
Basically, I have to build a “handler” function that decides first if the Cmd should be called. would be a lot easier if I could just collapse the logic into a single function though.