Dedicated Server in Standard Revisted

Ok I remember asking this question before, and someone said it was imposible to have 1 Unity Project acting only as a server, and another acting like a client. Well if this is true how is it that I made 1 project just now just as a server"host" and one as a client and it was abble to connnect? From what I understand the only thing a server needs to do is foward relvent data to the other players. Does this set up go against the eula?

It deffinatly does work I ran the client on my laptop and the server on my desktop no problem with connecting. So why not just script a dedicated server as one app then make your client as another stand alone app?

the problem with the distinct projects is that you basically can no longer use RPCs, because the RPCs unique ids that are sent when you call an RPC (its not their name thats beeing sent, that would be an overkill) are generated basing on the objects with network views and RPC functions and if the functions aren’t the same on both sides the rpc ids will missmatch and fail.

using distinct scripts to handle the network starting etc is no problem, just enable the one you want in the build and build it.
Just keep in mind that disable component does not impact many of the OnXY callbacks, only Start, Update, OnGUI and a handfull of the others.

well do you have to use rpcs your can you just serialize it and send it on its way.

Not working with RPC is kind of impossible / requires ugly hack arounds.

You can just use OnSerielizeNetworkView, but those writes must happen to a fixed size block of data, so you can not send 5 bytes, then 12, then 7 then 24. It would always have to be 24 (in this example - just the max you will send)
You naturally could have a specific network view that you use as communication channel and set it to delta reliable. That way it would work similar to RPC
But the horror / uglyness will be the branching / switching code to write/read the data to the stream.

Thats not quite true, you can send dynamic sizes as long as you know what your doing. This old post shows how.

//perlohmann

Cant you specify the rpc ids or is this something totaly different?

Also I know you use RPC’s to send stuff but are they also used for receiving as well?

RPCs are network functions. They are called on both sides: You call it on your side with the data → reliable ordered packet is created with the function id and data and is beeing sent → other side receives the packet → it parses the function id, calls the function thats assigned to this id and passes in the data

The ids are generated by Unity. I would assume that it runs over all functions with the attribute RPC and generates a string table and that those string table indices are used as IDs.

I don’t think it goes against the EULA (why should it?) - but the question is: Why do you want two different projects? From my perspective, having two different projects for client and server will just complicate your development significantly (aside from the troubles with RPCs others have mentioned in this thread). Most of the objects you need on the server will also be needed on the clients (not the other way round, of course :wink: ).

Unity is (almost) flexible enough to handle the differences between client/server conveniently in one project. I say “almost” because it currently doesn’t support passing conditional compilation symbols (“#if SERVER”) from the project to the compiler. However, you can write a script that does this via code-replacement for you (IIRC, I posted about this on Unity Answers).

It’s not that hard to programmatically remove anything you don’t need on the server (that’s the way I’m doing it) - or handle it the other way round: Only instantiate what you need (that’s the way I would be doing it if I started again from scratch).