x


How can I connect Unity to an SQL database in order to implement an MMO?

Hello, first of all I'd like to thank each and everyone who has dedicated their time into producing Unity, and tutorials, and to those who assist others with their needs.

Now then, as far as my question is concerned, what I am planning is creating a massive multi-player online (MMO), and I have a large map so far. I've read/watched most of the tutorials available, and I'm just waiting for my paycheck to invest into the Pro version of this; but I am curious as to how I'd be able to connect my client to a server, that will register play coordinates, items, stats, etc.

Any assistance on this subject would be great. Basically, I am interested mostly into connecting the client to a SQL database.

-- To make it easier for you/me to understand, I'm going to ask if you wouldn't mind explaining it, if the database was, "client".

more ▼

asked Apr 21 '10 at 06:24 PM

Travis 1 gravatar image

Travis 1
23 1 1 4

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

With this kind of set-up you would generally call the the unity app the "client", because it's the part of the system which the end-user uses to view and interact with the world.

Your client would never normally have direct access to the database. This would generally represent a significant security problem. What is more typical is that clients would talk to a dedicated multiuser server application using socket connections (for example, something like SmartFox server, or often - for MMOs - a custom written server app).

It's also the case with simpler database interactions - such as a server-side scoreboard - that your client would never access the database directly, for similar security reasons. Instead, your client (the game) would talk to specially written server-side scripts (eg, in PHP or ASP), which in turn would access the database themselves.

Therefore it's only ever server-side programs that are under your complete control which have authorisation to directly access the databases, and your clients (which are less trusted, because they're in your user's hands!) are restricted to making higher level requests via an API of your own design, which is restricted to relevant commands such as "SubmitScore", and "RetrieveScoreboard" in the case of scores, or things like "MoveToLocation", "TakeItem", "Say Message", etc for a multiplayer RPG.

This multiuser server would then deal with handling interactions in your world, and it would be responsible for interacting with the database behind the scenes to create, read, update and delete information from the DB such as user details and persistent world data.

For this reason, your Unity client need never know about the existence of such things as SQL, tables, records, etc :-) These are all things which should stay on your server, either as server scripts or within your multiuser server application.

more ▼

answered Apr 21 '10 at 07:14 PM

duck gravatar image

duck ♦♦
40.9k 92 148 415

So, from my understanding you are telling me that I would need to direct the client to a configuration file (PHP / ASP) that in turn would allow the client to connect and store data via a database?

Apr 22 '10 at 12:30 PM Travis 1

No, your client would interact with a multiuser server application (like Smartfox Server). That server-side application would then deal with the database. It would act as a 'middle man' between your client game instances, and the database itself. The client would never connect to the DB, nor supply SQL commands.

Apr 22 '10 at 01:04 PM duck ♦♦

@Travis - This is also called n-tier or 3-tier architecture when developing applications such as webapplications. Client -> Server -> Database (3 tiers)

Sep 05 '11 at 07:29 AM BerggreenDK
(comments are locked)
10|3000 characters needed characters left

I've made a tutorial, explaining everything, to connect and grab data of a database, chek it out! http://forum.unity3d.com/threads/77447-Starting-my-MMO-with-SQL-SERVER!-in-Javascript

more ▼

answered Feb 10 '11 at 11:29 PM

Daniel 15 gravatar image

Daniel 15
31

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x704
x679
x232
x104
x62

asked: Apr 21 '10 at 06:24 PM

Seen: 14533 times

Last Updated: Sep 05 '11 at 07:29 AM