Game Development Community

TX 3.15. Controller IDs get mixed up on changing players.

by Matthew Hoesterey · in Torque X 2D · 07/22/2010 (3:26 pm) · 1 replies

In PlayerManager.cs The "_players" list is added to the first time you create players input maps. Thing is if you exit your level and have players rejoin (so that player 2 could become the new player 3 and player 3 could become the new player 2 ect...) The old input maps are still held as they are never disposed.

So when you reenter the game 2 controllers will control the same character as the manager binds the controller to an input map that already has a different controller (if that makes sense)

To fix this when I unload my level I created a function in PlayerManger that clears the player data.

public void ClearPlayers()
        {
            _players.Clear();
        }

I have a feeling I found an edge case as I'm guessing most peoples games would not ever have players switching their player number as you do in a fighting game.

#1
07/22/2010 (4:59 pm)
Interesting, I had an issue similar to this. Its not really an edge case, TX assumes you will look into the input manager and figure out a good solution, the defaults that come with the platformer starter kit are also a bit limited, but easily built on like you did.