Skip to content

4 Architecture overview

rolandcahen edited this page Dec 30, 2015 · 1 revision

#Overview We are using Unity 5 as the main platform (client / server) and we chose to stay with a standard server for the backoffice and database part (LAMP).

The web server (LAMP Linux Apache MySQL PHP) is in charge of the Spaces, the user accounts, the objects (with their initial state) but does not run the simulation. Its role is only to give the initial state of a Space to a server and give all the needed data (Asset Bundles to download).

The Unity server is in charge of running the chosen space simulation and synchronize this with connected clients. The server runs the same “New Atlantis” app as the clients but in “server mode” instead of “client mode”.

##MySQL database : User, Asset, Space, Object

  • User : account that belongs to a real human user.
  • Asset : composite-audio-graphic-3d-interactive object created by a User (designer/artist/developer) in Unity and uploaded to a Space in the form of an Asset Bundle.
  • Space : independent New Atlantis world. It is not necessarly related to the Bacon Sound Houses concept : several Sound Houses could exist in one Space, or one Sound House could be split in several Spaces. The absolute rule is that one Space is totally independent : nothing communicates, exits or enters with/to/from the outside.
  • Object : Object referencing an Asset, put into a space.. You can have several objects referencing the same Asset. The Object has a position and rotation in the Space it belongs to.

##HTTP kind-of-REST web service : HTTP post, returns XML Used by the app to communicate with the database. Simple login/password authentication for now, could change for something better in the future.

##The Unity App Works both as client and server (and standalone). The data server holds the actual data and the initial state. Once a server is started it starts to simulate behavior of objects and their state start to evolve : a cube may fall or a ball might roll down the hill... We are using the authoritative server scheme, meaning that basically the server is running the entire simulation and send the objects state to the clients, that are running the scene without the logic (only rendering).

##Master server, Facilitor and NAT punchthrough Anybody should be able to start a New Atlantis server. Thanks to the Unity « Master Server » and the « Facilitator server », we should not have to worry about NAT addresses, firewalls, ports forwarding and server publicity. The clients are able to ask for the current running servers (in the real world) and the servers are able to register to this Master server (Hey ! I am running a server !). We can use at start the default Unity Master server, located at 67.225.180.24, but source code is available and we will be able to setup our own in the future (Volunteers?). Of course, in case of an event we could as well not use this and connect to an hard-coded IP. EDIT : deprecated since Unity 5.1 ?

##Multiplayer synchronization There are several ways to synchronize several clients together (so that they interact in the same world). All involve more or less an authoritative server scheme : the server runs the entire logic (physics, collisions, objects creations...) and the clients run an « headless » version of the same scene. This is not so easy to do with user-created content, because Unity was not designed that way (Second Life was designed that way). User could do very complex things in script, very hard to synchronize ! (for example, generate a complex mesh each frame). 2 approaches are being tested : Passive synchronization (On the server, watch the state of entities, and report any changes to clients - An AudioSource started to play on the server ? We start this AudioSource on the clients) and Active synchronization (The user (you) need to be aware that there is a Synchronization and implement the appropriate code to achieve this : Split the script in 2 parts : the logic part, and the rendering / deterministic part. The Server must be able to run the logic and send the state to the clients.)

We use the Unity built-in Network system (now deprecated since Unity 5.1 !) : http://docs.unity3d.com/Manual/net-HighLevelOverview.html NetworkViews are automatically attached to all the GameObject to synchronize, and give us the synchronization we need : State synchronization (basically transform : position/rotation/scale, but not only) : The server tell the clients that this Cube is now there !

Remote Procedure Calls : synchronized actions : Spawn a cube at that position, Download an Asset Bundle from the server, Create an avatar...

Not pure authoritative server : the user navigation is processed on the user side and Avatar position is sent to everybody and user camera position is not synchronized and remain local.

##Object creation Use Unity 5 to create objects.

Guidelines :

  • Keep your sub-object count the less you can.
  • Parent everything to one root GameObject, make a prefab and export to an Asset Bundle.
  • Keep your Asset Bundle size small, because every object needs to be downloaded by every client (but we have a Cache, so the Object will be downloaded only once!)
  • Work only in your folder (Assets//). This will make easier an export and a merge of your work into another Unity project..
  • Put all your scripts (if you have) into one namespace. If you are not using scripts, this should work, but if you are writing your own scripts, send them to me (jonathan@free.fr) because they need to be compiled in the main App.

###Custom scripts Actual scripts can not be included to Asset Bundles (only references). Objects can reference existing scripts, but a new script, for now, needs to be included in the viewer app to be available in the system. Workaround would be to build a .NET assembly using Mono Develop or Microsoft Visual Studio and use .NET reflection to make it available at runtime but still needs some work, and would give unlimited access to the scripts, which is something that needs to be taken care of. For now, this is not allowed. So the viewer needs to be recompiled as soon as we wants a new script to be used. More here : http://docs.unity3d.com/Manual/scriptsinassetbundles.html

###Upload to the platform

  • Create a prefab by dragging an object from your scene to your project Assets.
  • Right Click->Export New Atlantis Asset Bundle, save file to disk.
  • Put the generated .unity3d file in the Viewer Bundles/ folder.
  • Start the Viewer, and then go to MyNA->Import a new Asset...

##How to run or build the New Atlantis Viewer

  • Install the SDK in your Unity project
  • Open the NewAtlantis/Core/Scenes/NewAtlantisViewerX scene and build it for standalone (Mac, Windows, Linux).
  • If want to test your own custom scripts, you can use this scene, your loaded objects will work.

#New Atlantis entities

##Space A space is a container for objects. Space has nothing inside at start, and has an unlimited size. But the visitor is spawned at (0,0,-10) at start, looking at the origin.

##Asset/Object An asset/object is any Unity3D objet exported as an Asset Bundle, and put into a space at a given location/orientation. By default, objects are created at the origin, but can then be moved or rotated by the owner.

##Tool A tool is a standard built-in object that a visitor can use to do an action. Current tool list...

##Components A component is a standard script that a creator can attach to an object (and then export this object).

  • trigerring on trigger and collide.
    • sound
    • particle
    • animation
    • ...
  • Teleporter
  • Physics parameter changing (gravity, time scale...) ...

Clone this wiki locally