Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by EToreo · Apr 11, 2012 at 11:11 PM · networkingserver

Networking with master server - howto: get events and create game servers


Preamble:
I have downloaded the master server example and I am more than comfortable extending it.

I have 2 questions:
1) How do I extend the example unity raknet master server to have it automatically put players into "game servers" (no user choice) that are distinct (no network traffic between them, only the clients within them).
2) How do I extend the master server to capture events? I would like to be able to capture when a player joins, dies (and who they where killed by), and leaves so I can put it on a website for fun statistics.

Thanks for your time,
~Eric

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by J3-Gaming · May 09, 2012 at 10:06 PM

The master server is not used for game logic (player dies, ect)

Master server is only used to register devices as their own hosts, or find host devices to connect too.

Once you have this:

GAME 1

Device A - Host

Device B - Client

Device C - Client

GAME 2

Device A - Client

Device B - Host

ect, then you can start putting the game logic on the hosts with security and cheating checks between the clients to make sure the host is not cheating also.

EDIT: The last and hardest step will be to add host 'switching', that way when the host disconnects you will not lose the game state, another client can take over. I found your question because of what I am doing, What I have described above had taken me 3 scripts, about 150-200 lines each that include delegate callbacks. Basically wrap the MasterServer class, wrap the Network class, and then create a class for interaction. Because this code is non-blocking, I used delegate and events (Example: Finger Gestures plugin) for control.

Good luck, enjoy the next 20 hours of life.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image EToreo · May 09, 2012 at 10:30 PM 0
Share

Thanks for the tips. You are talking about Host $$anonymous$$igration ("sever host" leaves and the game does not stop). How did you implement this?

avatar image J3-Gaming · May 10, 2012 at 07:25 AM 0
Share

Well I am almost done it, it is no small task. You definably need a strong program$$anonymous$$g background with basic networking knowledge (Like how a host and client should communicate)

Some tips is to wrap everything into 3 different classes (like i said above) in a very exact flow-chart method. If you can't draw it on paper without lines crossing, get another sheet of paper.

The secret of everything is the method OnPlayerConnected(NetworkPlayer player) This is called when a client connects. player.guid can be saved and sent over an RPC to notify everyone this will be the next host if something happens.

avatar image
0

Answer by gecko938 · May 15, 2012 at 02:21 AM

My version of the play online button (quick match) works something like this:

  1. User clicks the play online button

  2. Game kicks off a query to the master server for existing matches (MasterServer.PollHostList())

  3. Wait for your OnMasterServerEvent() callback to fire with the MasterServerEvent.HostListReceived event. If any matches were found with available player slots, then try to join them

  4. If no matches are found on the master server, or they are all full, or the client fails to join them, game eventually decides to host a new server locally

As noted by MightyGoob, you want to do all that stuff asynchronously (UI shouldn't freeze while searching). You'll want some sort of simple state machine to keep track of where you are in the search/join (automated matchmaking) process.

You'll also want to ensure you've gone through connection tester (NAT type detection) before you start trying to join or host sessions.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

Networking Player Nametag 1 Answer

Best cross platform Http Library? 1 Answer

Console Application 0 Answers

How to use NetworkManager.ServerChangeScene ? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges