- Home /
Is it possible to create GameObjects dinamically from a server?
Hello guys,
I wanted to create a game which is going to use a SQL db and some server-side scripting (such as php). It's nothing big and it's not an online game but it requires some online features. I would like to know just if it is possible. I just want to create dynamic gameObjects using values which are going to be stored on a DB for their respective transform position .x, .y and .z properties.
$$anonymous$$ore likely it's a topic nobody who saw your question was familiar with. It doesn't sound impossible, though I personally have no experience to say definitively. Have you conducted some research on the subject? The keywords are strong and ought to yield some fruitful results.
The server can /and should) not create objects on the client. The client gets some values from the server DB (aka a position) and then creates objects.
Thank you! I figured out this is not a common thing to do this way so maybe there is a different way to approach this. I have done some research, sending data through php to unity and viceversa but as plain text... I don't know how safe and efficient is that... not at all.
Thanks for your answer :)
Answer by fafase · Apr 11, 2015 at 03:59 PM
You would be better off creating a json file that you store on the server. Then you get it with WWW and start parsing the data.
WWW www = new WWW(url + objectName);
yield return www;
// Should check if it worked here
string json = www.text;
JSONObject jsonObj = JSON.CreateJSON(json);
JSONArray object = jsonObj.GetArray("objects");
// then you continue parsing whatever data you need
// Finally you turn the data into actual game object
Your answer
Follow this Question
Related Questions
using SQL db instead of playerprefs (playerlocation) 0 Answers
Any good tutorials for using databases with unity? 0 Answers
How to integrate SQL database in game? 1 Answer
simple online storage for game? Any other way? 1 Answer
Get echo output from PHP script which is on an FTP server with C# 1 Answer