unity webGL game stiched to node.js

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
uh oh
Posts: 17
Joined: Sun Jul 27, 2014 7:28 pm

unity webGL game stiched to node.js

Post by uh oh »

hello, anyone knows whether it is possible, now that unity supports webgl, to create a mmo game in unity that would be running on nodejs?
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: unity webGL game stiched to node.js

Post by SpiritWebb »

You can look at the following:

http://lmgtfy.com/?q=nodejs+Unity3d

These below were two things to help

https://whackcode.wordpress.com/2013/09 ... o-node-js/ - Using node.js as a Game Server for Unity3D
http://stackoverflow.com/questions/1756 ... th-node-js - Connecting Unity3D with Node.js
Image

Image
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: unity webGL game stiched to node.js

Post by Jackolantern »

You can use Node.js as the server for an online Unity game, WebGL or no WebGL. That is because node doesn't just support WebSockets, but all socket types, including standard TCP and UDP. Granted, Socket.io is a bit more elegant that raw TCP sockets and handles a lot of stuff for you, but it is still much easier than writing a multithreaded socket server in Java or C#.
The indelible lord of tl;dr
uh oh
Posts: 17
Joined: Sun Jul 27, 2014 7:28 pm

Re: unity webGL game stiched to node.js

Post by uh oh »

Thanks SpiritWebb :D but i did walk that path already.

Thanks Jack. I guess to make myself more clear, what am imagining is to make the 3d world part of the game in unity while the rest (more static part) of the game with some js engine lib or just js and stitch those two parts together with a node server with its own db(like mongodb).

I'm not sure at this moment what just the web socket communication technology by itself can offer and if there are any restrictions with how a unity made webgl game could transfer (what type &/or amount of) data to node server.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: unity webGL game stiched to node.js

Post by Jackolantern »

I'm not exactly sure what the design of your game is, but I am not sure the JS layer in your description is needed at all. Unity does have a competent web player that works similar to Flash (it "takes over" a part of the web browser and simply projects the Unity player onto the browser, giving the look of a browser-based game). If that is the direction you are going, Unity has much more advanced networking itself than Javascript, since Unity allows binary socket data transfers and UDP. Both of those are very important to allow twitch-based multiplayer, whereas WebSockets are stuck with TCP and plain-text transfer. I mean, TCP and plain-text transfer are better than nothing for Javascript web games and are a huge step up from AJAX alone, but Unity should have it beat hands down by simply connecting your node server directly to your Unity web player binary.

Note that I have not actually used the web deployment of Unity, and am making the assumption that its normal networking capabilities are present in the Unity web player (I am pretty sure they are).
The indelible lord of tl;dr
uh oh
Posts: 17
Joined: Sun Jul 27, 2014 7:28 pm

Re: unity webGL game stiched to node.js

Post by uh oh »

One thing is that a no-plugin browser game seems to me far more accessible and the unity web player seems to have one foot in the grave anyway according to their own expectations.
But even if it is possible to create plugin-less browser mmo in unity with photon server or something I guess the main reason behind my approach is that the fancy 3d part of the world would need just some basic collision for not walking into objects and there’s gonna be some minor interaction like talking to players taking place (no twitch based action). The vast majority of the game would be pretty much just turn based fights and setting stuff (nothing that couldn’t be pulled of even with php).

I have to admit that probably from the most part I am restricted by my knowledge of these aspects - I can vaguely imagine how to create a very simple 3d game in unity where you just walk and point at objects and I can vaguely picture how to create main logic and the UI in js.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: unity webGL game stiched to node.js

Post by SpiritWebb »

Jackolantern wrote: Note that I have not actually used the web deployment of Unity, and am making the assumption that its normal networking capabilities are present in the Unity web player (I am pretty sure they are).
The normal networking are present for any type you deploy to. Whether it be a standalone, an app or for browser-based. Though at present they cannot handle a full MMO ( if I remember right as I use Unity3D ), and would need a third party for that part. But the Unity's version of multiplayer would work great for a LAN style game and would work in the browser.
uh oh wrote: I guess the main reason behind my approach is that the fancy 3d part of the world would need just some basic collision for not walking into objects
To simply add a collison to prevent a player walking through an object, you would just ADD COMPONENT -> PHYSICS -> MESH COLLIDER or BOX COLLIDER around the object you do not want the player to walk through. This can also be done on an empty object to keep the player from leaving the game area.
Image

Image
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: unity webGL game stiched to node.js

Post by Jackolantern »

uh oh wrote:But even if it is possible to create plugin-less browser mmo in unity with photon server or something
Unfortunately, I don't believe a plugin-less browser game can be made with Unity. Unity doesn't run natively in the browser, so if you absolutely wanted to go plugin-less, you would want to start looking at native WebGL game engines and WebSockets for networking. As of right now, I would say that Turbulenz Engine is probably the most advanced and "Unity-like" WebGL game engine. I don't believe it requires a plugin.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: unity webGL game stiched to node.js

Post by hallsofvallhalla »

simple answer is yes, i have connected Nodejs to Unity and was one of the first to make unity work with PHP way back in the day. It will work.
Post Reply

Return to “Beginner Help and Support”