Hello.
I'm working on a multilayer game. were one player can use a keyboard and the others can us Xbox controllers. the order won't matter.
I"m able to tell the difference in input just fine. My problem is assigning a control device to a player and over multiple layouts.
what I want is you start at the player start up screen/layout. here each player would press "A" on there controller to say that it's in use. (meaning you could use controllers 1,2 and 4, but not 3)
then as they went to the next layouts(depending on the level they select) each player would be given control of a random NPC that is on the stage. this would repeat though all the layouts.
How I had it set up in my test layout when I first started was making a global variable that I would set to the number of players I wanted. it would then create an object called "player" once for how big the variable was. and increment a variable inside that instance to tell it what controller it had.
Then in the main loop were input would be collected I had a "for loop" that would go though each Player instance. And looking at it's variable would collect input from that device, and apply it to the NPC by means of an ID the NPC has. (each player object holds this id so it knows what NPC this player controls)
This worked well... when the project was one sheet. however now I'm not sure how to carry the player input data over from the start screen. is there a way to spawn my "player" objects in my start screen. then have them stay throughout the game? or should I store the data in global variables? and if I store them in global variables how would I reference that in a forloop for each player?
Thanks much