Monday, December 20, 2010

Unity3D Successful Login

This is the last of these tutorials. With this we will have a fully working setup where you can create users. You can allow them to log into your web application. And you can use the same login to allow them into your game. This also allows you to develop the web site using the same database so data will match between your game and your web site which is handy as it is one less thing to keep up to date in 2 places fulfilling our DRY principle.

Lets start by opening LobbyGUI and adding our new handler under the publickey handler:


handlers.Add("loginsuccess", OnLoginSuccess);


and lastly we add our OnLoginSuccess function:


    void OnLoginSuccess(ISFSObject data)
    {
        UnregisterSFSSceneCallbacks();
        Application.LoadLevel("CharacterSelect");
    }

We need to make sure we unregister the SFS callbacks or you will end up with some funky messaging errors. Lastly we load the new level. Make sure you create this scene and add it to the build properties, otherwise you'll get an error trying to load the new scene.

There you have it. We took Symfony, Unity3D, and SmartFoxServer and wrote the beginning to your very own online game. From here you can expand it however you like.

I am considering putting the files together to a downloadable for a nominal fee, say $10. If enough interest is generated, I'll work on packaging up the extension, entity project, and Unity3D code for people. Leave a comment if you would like to see this happen.

2 comments:

Anonymous said...

Thanks for a great tutorial!

Would I be able to use this approach with Kohana?

Unknown said...

I haven't used kohana before. The only thing I can think of is that 1) the table name in MySQL will be different and how they store their password will be different. Otherwise everything should be exactly the same.