Hi:
I have built a small multiplayer maze “game” which is attached for
anyone who might find it useful. I debated putting it up on the
showcase forum instead. But that’s not really why I built it. It
was intended more to help me understand how to get some of the
networking stuff going and I thought others might reap a little
benefit from my efforts.
–ralph
The contents of the README:
The disclaimer: there is no warranty whatsoever on this software.
This is a multiplayer maze “game” built with Unity.
It’s really just a maze that multiple players can move around in.
The walls are built by a script that has a simple maze coded
directly in as an array of point values.
It is not elegant, but is minimalist and functional. It should
accept an arbitrary number of players, but I have only tested it
with the server and 2 clients. Only the first player gets a red
ball; all others will get a green ball. But, based on the present
content, it should be pretty obvious how to give a different colored
ball to each player. In fact, a better approach would be, instead
of using the 2 existing prefabs, to have a single prefab, and just
alter the color as each instance is given out.
I can run it on my laptop starting several instances of Unity all
at once. (I have also tested running instances on multiple hosts.)
I start the first just by clicking on the Unity App. Then after
the first, I start them via a terminal by using this alias in tcsh:
alias unity “/Applications/Unity/Unity.app/Contents/MacOS/Unity”
To fire up the server, I start the game and then click the “Start
Game” button, then just watch messages in the console. To fire up
a player, I start the game in another Unity window and click the
“Join Game” button and watch the messages in that console.
** This is probably the most important point when running multiple
instances of Unity on a single host: I have to keep clicking the
server to make it update. This means that after a player prints a
message saying it has connected to the server, I don’t believe it.
Instead, I click the server to make sure. Then, I click the player
window again, and then click the “Create Ball” button. If I click
to create a ball without first clicking the server, it will fail.
If you have multiple players, you have to move the ball for one
player, click the server, then click to player 2, move its ball,
click the server, etc. If you click the server after every set of
actions on a player, all players can successfully see each others
movements. This is a bit of a hassle, but is OK for testing on a
single host and not a problem on multiple hosts.
58646–2134–$mpmaze_tar_562.gz (449 KB)
