Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • General Discussion /
avatar image
Question by k-krrs · Aug 21, 2018 at 12:54 PM · Custom Game Serversdocumentation

Multiplayer with authoritative server hosted by PlayFab with Unity Networking

The documentation is very vague on this subject, and I'm an absolute beginner with networking. I don't know where to start with something like this. Basically what I need is to have a server which takes inputs, simulates a game and sends back transforms to all clients. How can I do this with PlayFab and Unity networking? I'm having a hard time figuring out how PlayFab and UNet will work together. What do I need to do, as in what needs to be included in the build on PlayFab, how to connect to it etc.?

Comment

People who like this

0 Show 0
10 |1200 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
Best Answer

Answer by Andy · Aug 21, 2018 at 11:20 PM

<Posting a new answer as I was running against the character limit>

Great! I can't comment on exactly how it would work in Unity's Network Manager, but I can explain how the PlayFab side of things works. For now, I'm going to assume you're using PlayFab's server hosting and matchmaking.


When we determine that a new server instance needs to be started, we push your exe onto a VM and then start it via a command line. You have a lot of leeway in how you define this command line, but our example looks like this:

-game_id=<game_id>
-game_build_version=<game_build_version>
-game_mode=<game_mode>
-server_host_domain=<server_host_domain>
-server_host_port=<server_host_port>
-server_host_region=<server_host_region>
-playfab_api_endpoint=<playfab_api_endpoint>
-title_secret_key=<title_secret_key>
-custom_data=<custom_data>
-log_file_path=<log_file_path>
-output_files_directory_path=<output_files_directory_path>
-batchmode

Notice that we're telling you the host domain and port that you should start listening on. You'll need to figure out how to take those parameters and provide them to your networking layer.

Additionally, once your server instance is up and running, you can register it for Matchmaking by calling our RegisterGame API. You'll also want to send out a heartbeat and deregister once you have things working.

This is all explained in greater detail in the tutorial I linked earlier: https://api.playfab.com/docs/tutorials/landing-tournaments/multiplayer-servers.

Comment
k-krrs

People who like this

1 Show 5 · Share
10 |1200 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 k-krrs · Aug 22, 2018 at 07:25 PM 0
Share

What data types are each of the command line parameters? Or do I just take them as strings?

avatar image Andy ♦♦ k-krrs · Aug 23, 2018 at 12:15 AM 0
Share

I'd recommend treating them as strings.

avatar image k-krrs · Aug 22, 2018 at 08:46 PM 0
Share

Also I am confused as to whether I need to call Register/DeregisterGame and a Heartbeat if I'm using PlayFab's hosting and PlayFab's matchmaker.

avatar image Andy ♦♦ k-krrs · Aug 23, 2018 at 12:19 AM 0
Share

You should still call register and deregister, but heartbeat isn't necessary.

avatar image Andy ♦♦ Andy ♦♦ · Aug 23, 2018 at 06:46 PM 0
Share

Scratch that. I was mistaken. None of the register, deregister, and heartbeat calls are needed when using PlayFab hosting.

avatar image

Answer by Andy · Aug 21, 2018 at 08:49 PM

Honestly, the first thing I would focus on is getting your server working and clients connecting to it without thinking about hosting or PlayFab at all. That will get you to the start of this guide here: https://api.playfab.com/docs/tutorials/landing-tournaments/multiplayer-servers.

Once you've got a functional dedicated server, then you can start thinking about things like discovery, matchmaking, and hosting. That is where PlayFab can offer solutions to help your game run at scale. As you start to dig into that later class of problems, I'm happy to answer questions you come across.

Comment

People who like this

0 Show 1 · Share
10 |1200 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 k-krrs · Aug 21, 2018 at 10:17 PM 0
Share

I already created a functional server (somewhat - only allows movement right now) and since I'm using Unity's Network Manager I'm not sure how the server will know when I upload it on what IP to use. Currently I connect via localhost:7777 but that needs to be set in the editor. How will the server set it to use its own port and its own IP?

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.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Multiplayer 2.0 Resources/Documentation/Tutorial 1 Answer

    what if we decided to move our game from playfab to custom backend infrastructure in future?,what if we want develop a custom backend for our game in future ?? 1 Answer

    what if we want to stop using playfab and shift our title to our custom backend in future after a year from game launch 1 Answer

    I want to develop the game by Unity and configure the server using UWP. Which document should I refer to? 1 Answer

    Playfab instance costs & resource allocation? 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges