Game Development Community

Couch co-op and keeping track of players

by Sean Monahan · in Torque X 2D · 12/19/2008 (7:01 pm) · 0 replies

I'm looking to add two-player local co-op -- we'll call it "couch co-op" -- ala side-scrolling Contra to my game and looking for some input on keeping track of which player is controlled by what controller. I'll give an example:

T2DSceneObject player = PlayerManager.Instance.GetPlayer(0).ControlObject as T2DSceneObject;

That will get me a reference to player 1 (i.e., player index 0) which is all good and well if there will only ever be one player. So I'm looking for a way to replace the 0 with some variable that will give me reference to a specific player that will be determined at runtime.

Has anyone else faced a similar situation if so, how did you solve it?

Any thoughts?