11
\$\begingroup\$

I was wondering if there's any way to know if the "player" is signed in or not?

Something like this:

if (GamePad.GetState(PlayerIndex.Two).IsConnected && !Gamer.PlayerTwo.IsSignedIn)

So that the controller is connected and it can be used, but the player is not signed in to an account. Something like a guess.

\$\endgroup\$
11
\$\begingroup\$

In XNA there is a SignedInGamer class with a SignedInGamer.PlayerIndex member that should tell you just that if you can get a hold of the SignedInGamer object.

To do that, there is the Gamer.SignedInGamers static property which contains a collection of SignedInGamer objects based on the current state of the system. This is from the Microsoft.Xna.Framework.GamerServices namespace.

With this information you could do something like the following:

//If player 2 is connected
if (GamePad.GetState(PlayerIndex.Two).IsConnected)
{
    //If we can't find a signed in gamer with a PlayerIndex of two
    if (!Gamer.SignedInGamers.Cast<SignedInGamer>().Any(x => x.PlayerIndex == PlayerIndex.Two))
    {
        //Your handling code here
    }
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.