Google Cloud Platform with Unity [closed]

2019-07-27 01:31发布

问题:

I was thinking of Google Cloud Platform (GCP) as the backend for Unity.

Can someone guide me to develop the GCP flow as authoritative, like if a request comes for deducting X gems to convert into the amount, then GCP get gems conversion rate from metadata, calculates the amount and increments amount in the user gamestate, also returns the new total balance as a callback [Remember: metadata/gamestate is saved in MongoDB (JSON)]

As i worked with AWS servers, so i want to know how to do it in GCP.

Any help regarding this will be appreciated

回答1:

You're basically asking "how to cloud host my game server" here which is an extremely complex question.

The process is exactly the same as you did with AWS in the google infrastructure.



回答2:

If you're looking to run a server in the Google Cloud, you must remember that Unity is just a piece of software, with full access to C#. This means you can utilize the entirety of the .NET framework, Mono, .NET Core, or whatever other C# libraries to accomplish whatever task you wish.

The simplest method of getting a server running, as I've seen it done before, is to use NodeJS. NodeJS is pretty fast, and I had a friend have working multiplayer using NodeJS alone. This means that you can get a backend working without much effort, ASSUMING you do not have to also have a website pulling data off of this. This would be where I'd start with that endeavour.

If you want to stick to C#, there's another alternative called ASP.Net Core. Microsoft recently released something called .NET Core, which means that you can run .NET (sort of) code on Linux, Mac, etc. Either way, with C#, you're going to be needing to make post requests via Unity to the web server, and process the returned JSON.

And finally, if you want to stick to C#, but not use ASP.Net core, you can always just use sockets, or write your entire web server from scratch using a technology of your choice.

But, the most important thing you should take away from this is that Unity is capable of running C# code as software itself, outside of the game. All .NET code is accessible, for example, if .NET is installed on the machine. This means you could, theoretically, set it up with Mono, and use Mono instead. Unity is just an engine processing graphics, physics, and input entirely for you, with a layer that exposes C# scripting for you (where C# is an intermediate language).

Best of luck.



回答3:

Your Unity backend logic for dealing with gems needs to be loaded onto Virtual Machines to run your gem conversion computations. The Google Cloud Platform provides different types of VM compute options to run your gem conversion logic on (e.g. App Engine and Compute Engine), which are accessible by calling URL Endpoints from your Unity clients to communicate with via JSON.

These Virtual Machines can then connect to databases to store your gem and user gamestate information so that you may save user gaming records. It is recommended you read the Google Cloud Game Server Reference Architecture guide, where it mentions using Google Cloud Datastore as your scalable cloud database solution.

You might also want to check out Firebase Cloud Messaging to provide fast gaming updates to all of your Unity clients to do things like informing everyone of a user's new gem count.