Gamepad Issue

0 favourites
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hi guys,

         So Im making a local multiplayer game and Im looking to simplify the events. It will have up to 4 player, and you play with 4 gamepads. Every sprite being controlled by the player is exactly the same. I was wondering if there is a way to give the sprite a variable, name it "Player" and give it a number 1,2,3,4... And have it set up so that that variable is used to detect input from its matching controller. Basically, streamlining the control events by only having to write them once, instead of once for each gamepad.

    Thanks for any help.

  • If I didn't make that clear enough, I basically want to make my events go like.. if any gamepad button A is pressed.. if Playersprite.Player is equal to Gamepad.. Simulate jump. So if its the second controller, only player two would jump.. and so on.

  • that's exactly what i was wondering too :D

    I haven't found a good solution yet but if you want we could exchance our .capx to see how eachother dealt with the controllers. I'd be interesting to see i guess.

  • Well , each gamepad has a different id , eh ?

    I never played around with the gamepad object , so this is just ontop of my head

    Give each player an id variable that corresponds to the id of the gamepad you use to control the player with

    And the

    On gamepad key pressed

    If player.id = gamepad.id

    Do action

  • Hmmm, let me try that. I tried a variation of that, but had no luck.

  • The Controller Id just sends a string listing make and model, not an actual number. Does anyone know how to get the number?

  • philx Sorry, its a full game project. Im not really comfortable sharing it. No offense. :)

  • allright this is understandable. So I'll just send you mine.

    It was my second attempt, so im sure there are loads of improvements but maybie it will help you in some point.

    docs.google.com/file/d/0B7m-eoWIKsSMa0dvQTdOOW9ldzA/edit

    I'll try what Whiteclaws said as soon as i'm back from hollidays and if i get to a acceptable solution, i'll share it in this thread.

    Edit: PS: if somebody is interested in the Joystick PNG's, send me a message

  • have you found a acceptable solution yet?

  • Well , each gamepad has a different id , eh ?

    I never played around with the gamepad object , so this is just ontop of my head

    Give each player an id variable that corresponds to the id of the gamepad you use to control the player with

    And the

    On gamepad key pressed

    If player.id = gamepad.id

    Do action

    are we talking about the pre-set UID or the manually settable instance variables?

    i'm working on something to get this correct atm but i dont really come to a working result.

    EDIT: Whiteclaws i'm sorry, stupid question. it's not instance variables. but how can you set the same ID for the gamepad1 and the player1?

  • read the manual, it explains how to pick gamepads by index.

    always read the manual first

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • philx I have not yet found a way to do it. And either way works, I just dont want to repeat the whole list of commands for 4 controllers, when it seems like it should be simple to call on certain sprites with certain controllers, without having to set up code for 4 different controllers.

  • read the manual, it explains how to pick gamepads by index.

    always read the manual first

    Sargas You obviously misunderstand the issue. I have read the manual several times, it does not explain a way to do what I ask. So in turn, I ask you to READ THE QUESTION before jumping to conclusions.

    Thanks

  • yeah i totally understand your issue and i am facing exactly the same "problem".

    i tried to solve it with families and instance variables now but couldnt get either to work. so maybie ill just make an event for each of the four players -.-

    Sargas you completely misunderstood our problem here.

  • philx I tried the families too. It seems like something so simple to pull off, but there just doesn't seem to be a way. Im sure there is something. I work on about 10 projects at a given time, as soon as I return to it Ill let you know of any progress I make.

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