I’m working on a little project that involves the ownership of land, buildings, and even units. Think of it a bit like an RTS. Try as I might, I haven’t successfully found any resources on connecting anything close to that nature to uNet or PUN (Currently using uNet and intend to stick with that), so I have a few questions about it:
First, how would one go about telling the project who owns what, and giving interesting controls only to the right people? While we’re at it, what about multiple owners of the same content?
Second, is the ‘ideal way’ of keeping track of ‘this’ player’s main character, buildings, etc, storing it locally on creation, or is there a better way to go about figuring that out? This leads into the question about utilizing mouse clicks on objects for the sake of controlling or otherwise interacting with objects on behalf of a particular selected character/unit/etc.
Pretty much just need help with the finer details of how ownership is determined and even changed from one person to another… and how to make something ownerless, while we’re at it.
If you have multiple owners for 1 object then [Command] will not work.
You can use UNET message to send information (for example you could send NetworkIdentity.id, vec3 move location). The server could then decide to accept/reject this message based on ownership. The server could also tell clients who are the owner(s)… unsure the best way on this one though (messages, rpc’s, a syncList of owners might be some things to try) https://docs.unity3d.com/ScriptReference/Networking.MessageBase.html
Do you happen to have a link describing exactly how to use those? After hours of looking around, I’ve only found vague information pieces that don’t really give me the full picture on how to use them… or even how exactly to write a basic script to see it work.
Hmm… so the… method gets sent to the opposite of what’s calling it? So, say I call a method that just changes a variable from the server, it’ll just change it on the client? What’s msgType?
msgType is a ushort ID that is unique to this message. i.e. use MsgType.Highest + 1 for your 1st message, and +2 for your 2nd, etc.
Yeah if you want to send the server something
-Instantiate message on client
-Assign serialized data in the message instance on client
-Send the message to server
-Server reads message and invokes it’s associated registered readMessage method
So basically keep an integer and increment it every time… does it have to be different every time even when you’re swapping between client and server calls?