A few unity/smartfox questions

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

tosha96
Posts: 3
Joined: 03 Sep 2010, 16:25

A few unity/smartfox questions

Postby tosha96 » 05 Sep 2010, 05:22

So, I've started using smartfox with unity and I have a few questions. I have not been able to test anything until now (Because my OS's java was corrupted) but I was able to come up with a few things I would like to figure out. I don't want this post to be a "I aM macking a MMO but i don no how" sort of post, but if it does turn into that feel free to tell me that I should just go look at the docs. :wink:

1: Can using smartfox plugin with unity basic? So, I was looking at the example projects and I saw they all had the API .dll file in the plugins folder. Since unity basic does not support plugins, would it still work if I just made a folder called Plugins and stuck the .dll file in there?

2: How to handle extension responses? So, making the extension itself seems pretty straightforward, but having unity respond to the server is confusing to me. It seems like everything is handled in the OnExtensionResponse function, but there is also the sfsobject class which takes care of the actionscript object data stuff that the server sends out. Is the sfsobject class its own function where the extension data is handled, or is it a sort of paramater that the OnExtensionResponse takes that will handle the object data that the server sends out. Also how does the client side define which different packet of data is which? Do you have to add some sort of identifier to the object in the extension? And how about vice versa, how does the server define the different client objects? (This question is my biggest roadblock for me, once I figure this out I think it will help me understand my other problems.)

3: How should I adapt the login scripts in the extension cookbook? The programming my team needs done most is a simple mysql database login script. I have been trying to adapt the script in the extension cookbook, but I'm not having much luck. (Once I figure out #2, this may help me with the login.) Also, how does the client respond to the login script? From the code it seems like it just prints a message to the screen saying that you are logged in. Is there any additional processes needed to officially login the client? Also, how would you define the nick and pass values in the client? Would you define them as global variables and then create a separate function to read them from a SFS object that the client sent?

4: Do you have to script the transform syncing, or is it automatic? There's probably something about this in the sfs island demo, but I have not really got to it because i've been working on the basics.

Thanks for any advice or answers, its really appreciated! :D
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: A few unity/smartfox questions

Postby ThomasLund » 05 Sep 2010, 09:35

tosha96 wrote:So, I've started using smartfox with unity and I have a few questions.


Welcome - and ask away!

tosha96 wrote: I have not been able to test anything until now (Because my OS's java was corrupted) but I was able to come up with a few things I would like to figure out. I don't want this post to be a "I aM macking a MMO but i don no how" sort of post, but if it does turn into that feel free to tell me that I should just go look at the docs. :wink:

1: Can using smartfox plugin with unity basic? So, I was looking at the example projects and I saw they all had the API .dll file in the plugins folder. Since unity basic does not support plugins, would it still work if I just made a folder called Plugins and stuck the .dll file in there?


Yes - you can use dll plugins when they only contain assemblies - the Unity Pro plugins that they talk about are C++ plugins. A very common source of misunderstanding. So simply do similar to the examples and you are safe!

tosha96 wrote:2: How to handle extension responses? So, making the extension itself seems pretty straightforward, but having unity respond to the server is confusing to me. It seems like everything is handled in the OnExtensionResponse function, but there is also the sfsobject class which takes care of the actionscript object data stuff that the server sends out. Is the sfsobject class its own function where the extension data is handled, or is it a sort of paramater that the OnExtensionResponse takes that will handle the object data that the server sends out. Also how does the client side define which different packet of data is which? Do you have to add some sort of identifier to the object in the extension? And how about vice versa, how does the server define the different client objects? (This question is my biggest roadblock for me, once I figure this out I think it will help me understand my other problems.)


Yes - the system is very generic, and you are on the right track with your thinking. You decide how to identify the objects you are sending. E.g. adding a "id" parameter with some value in it as a generic convention. Then client side you have a switch/case in OnExtensionResponse to identify what was send to you - and then you can either
- send the data off to a given class for handling the content itself (e.g. a chat manager if it was a chat - or a RemoteAvatarTransformManager if you got a transform of a enemy unit)
- handle it all inside the switch/case

For simple stuff, simply handle it right away imho

tosha96 wrote:3: How should I adapt the login scripts in the extension cookbook? The programming my team needs done most is a simple mysql database login script. I have been trying to adapt the script in the extension cookbook, but I'm not having much luck. (Once I figure out #2, this may help me with the login.) Also, how does the client respond to the login script? From the code it seems like it just prints a message to the screen saying that you are logged in. Is there any additional processes needed to officially login the client? Also, how would you define the nick and pass values in the client? Would you define them as global variables and then create a separate function to read them from a SFS object that the client sent?


Can partially answer - lots of questions embedded in the above ;-)

If you override the internal login, there are several things you need to do manually. The cookbook should give you some of the hints. Besides implementing your own logic to verifying the login, one of the really important parts is to send the roomlist. This is usually done automagically in the build in login. Without the roomlist you are fubar. These things are not Unity specific - I'm very sure you can find some full examples + other hints in the forums and the documentation.

tosha96 wrote:4: Do you have to script the transform syncing, or is it automatic? There's probably something about this in the sfs island demo, but I have not really got to it because i've been working on the basics.

Thanks for any advice or answers, its really appreciated! :D


The island demo has basic transform sync + also animation sync. These things are done in a non-extension scenario though, where the code sends out the transforms using only SFS server as router. Poke me a pm with your email address, and I can send you a FPS example that uses the same mechanisms but using server extensions.

/Thomas

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 1 guest