Question

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)

Edit:

This way the controller is connected (the player can use the controller), but it's not signed in to any account, something like a guess.

Was it helpful?

Solution

I'm answering this to mark it as answered, but please don't vote me up since I didn't answer it, go to: https://gamedev.stackexchange.com/questions/58616/how-to-know-if-the-player-is-signed-in/58618?noredirect=1#58618 and vote ToddersLegrande answer up.

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
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top