Unity and Smartfox Server logic sharing!!

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

rickygulgul
Posts: 1
Joined: 25 Jan 2019, 10:13

Unity and Smartfox Server logic sharing!!

Postby rickygulgul » 25 Jan 2019, 10:19

I'm going to have a singleplayer and multiplayer mode. I want to avoid having 2 versions of my game logic. What's the best way to do this? My best guess is writing all core game logic in C++ so that it can interface with both Unity (C#) and SFS (Java), but maybe there's a better solution suited for this.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity and Smartfox Server logic sharing!!

Postby Lapo » 25 Jan 2019, 15:20

Hi,
it's difficult to say, without knowing the details of your project.
For some games it can be relatively easy to hide the multiplayer side in a transparent way. Essentially you need a layer of abstraction that can be swapped at runtime based on which game mode you're playing (single player, multiplayer).

So for example you will always have a "Connection phase" at the beginning of the game: in SP mode you won't need to do anything, while in MP mode you will have the SFS2X client API performing the connection to the server.

I am not sure about the C++ logic interfaced with Java. Running C++ code in SFS2X it is possible on paper, as Java allows to integrate native code, but it's quite frankly a pain in the ass, pardon my French :)
Also SP and MP logic will differ quite a bit because in SP mode you need to create an AI logic that behaves like a player does, while in MP mode you just validate the players' commands. They are two very different things, might as well write the server logic in Java and avoid the problems that C++ inside Java provides.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 30 guests