How do I multiple inputs

0 favourites
  • 3 posts
From the Asset Store
Supports keyboard, mouse and gamepads. Supports several gamepads at once.
  • 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

  • Add an unique invisible sprite for each player in your start screen and make these global objects.

    Store your settings for the player in the sprites variables, and use the sprite for each player to reference them in your game.

    The global object will not get destroyed and will keep the information.


    Player1sprite.controller = 1 = player 1

    Player2sprite.controller = 2 = player 2


  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • awesome. thanks man!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)