Hello. I know this question has been asked in the past, but cursory searching didn’t yield too many recent results. I am new-ish to Unity and new to multiplayer. I make a lot of mistakes. I’ve gotten to the point in my project where I need to take it online, and I am wondering if there is a way to test my multiplayer features in the typical trial-and-error manner without having to build it every time. Is there some way to run multiple instances of the game in the editor? Or have an external build that updates itself as I make changes?
If someone knows of a way to do this, it would be a huge help for me and save a lot of future frustration.
1 Like
The new unity DOTS Netcode can do that. There’s a bit of work involved in later on actually getting in on an external server, but it gets you most of the way there.
2 Likes
Currently there is no way to run multiple instances in the editor. A workaround for now which works decently is to use Symlinks to clone your project that way you have two identical projects which can be run in separate Unity editors. UnityProjectCloner GitHub - hwaet/UnityProjectCloner: A tool to let the user to create a duplicate project that links back to the original, for multiplayer testing is a package which does exactly that for you.
2 Likes
Get a second computer, use version control to sync the project to the second computer. Run in editor on both computers. If your computer is powerful enough, you could try using a VM instead of a second computer.
I just said the above, but in my own experience I find that when I make changes those changes typically affect either the client or the server but often not the behavior of both. So I usually get away with just using the last build of one and the new changes in the editor. When they affect both is usually when I’m adding some entirely new functionality which depend on both client and server. YMMV
2 Likes
I hope this will be worked on in the future for game object multiplayer networking. I saw something similar to it in the new DOTS Networking. But this should be built-in as a package imo.
2 Likes
I’ve been playing around with the unity DOTS netcode for a bit now, and it’s actually pretty good. It’s starting to feel “built in”. Especially after some recent changes that really streamline the process, removing a lot of “boilerplate” code. I would recommend checking out a few videos so you can see what to expect. I would also recommend doing a few Dots tutorials (no netcode) first to understand how the entity-component workflow is set up.
But my current workflow goes something like this.
-
Make some changes to client code:
-
run server and client simultaneously in unity editor to test connections are still working, no breaks.
-
make some changes to server code
-
run both simultaneously again to test.
When I feel confident my changes are good, I build a server.
-
Then in unity editor I only run a client to check that compilation didn’t break anything.
-
Check this server app with Amazon GameLift local (basically runs it through their API but locally)
-
Upload server app to Amazon GameLift, get a fleet running etc. (that’s a whole bag of worms!)
-
in unity editor run only a client again, make sure connection works. Everything still good.
-
build client. test completely outside unity editor.
I’ve found this workflow to be pretty great cause you can test all your direct networking within the unity editor before any building whatsoever. Then later on step by step test whether it still works with your hosting service, while still allowing for local changes to client code. Then finally do a full build to test.
I know unity is now making sure packages are super clean before they are considered “released” but I think last year this package would have been shipped already with their old standards. It seems super stable to me now. However, the documentation is DEFINITELY lacking. But the folks on the forums have helped me through few problems, the devs actually seem to post quite a bit too to help out. As evidenced above.
@AdamBebko @luke-unity @Joe-Censored
Good suggestions, all. Thanks. It turns out that, for now, my project is light enough that building every few minutes isn’t really an inconvenience. I’ll keep these workarounds in mind for when they are needed.
1 Like