Sign In Register

How can we help you today?

Start a new topic
Answered

Multiple local users

I was wondering if there's functionality to have more than one user signed in at a time. Our game can have 8 local players, and it would be nice if players could login and access their own unlockable character customization options.


Best Answer

In case anyone comes across this and is curious, here's what I did to make it work for multiple logins.


Since each GSInstance needs it's own Platform (otherwise each signin overrides the last), I modified PlatformBase.cs to store a GSInstance, which I set in each platform I make. Then I made sure in OnApplicationPaused and OnDestroy, I used this instance instead of the static one it used before.


Hi There!


The base C# SDK does support this, but you'll need to fiddle around a bit to get it to work in unity.


You can create multiple GSInstance instances, with each being logged in as a different player.


The standard GameSparksUnity object uses a static reference to GS (which is just a wrapper around a GSInstance.)


Have a look and see what you think, if you have question while trying this out feel free to hit us up!


Gabriel



Will do, thanks!

Answer

In case anyone comes across this and is curious, here's what I did to make it work for multiple logins.


Since each GSInstance needs it's own Platform (otherwise each signin overrides the last), I modified PlatformBase.cs to store a GSInstance, which I set in each platform I make. Then I made sure in OnApplicationPaused and OnDestroy, I used this instance instead of the static one it used before.

I had the same requirement as Hive Mind and similarly modified PlatformBase. I see that when sending messages the various Request constructors have an overload that takes a GSInstance to use. Sending requests is essentially working with this technique - thanks!


But I wonder how to handle message listeners - I don't see how to associate a listener with a particular GSInstance such that each of my local players can handle their own messages. I see that the messages themselves have a gsInstance property. So presumably I could set up a global listener and dispatch the messages to each player "manually". But I'm hoping there's an easier way - analogous to passing the GSInstance to the equest constructors.

Login to post a comment