How do I program gamepad controls for multiple players only once?

0 favourites
  • 3 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • I am currently working on a local multiplayer project that can have up to 4 players at the same time with gamepads.

    I really don't want to have to go through the repetitive task of programming all the controls for each individual player, and I was wondering if there's any way of doing it only once and make it work for all players.

    Currently, I have all player objects be part of a family, and its instances are always in order (Family.IID(0) = Player 1 | Family.IID(1) = Player 2 | Family.IID(2) = Player 3 | Family.IID(3) = Player 4).

    Is there any way I could perhaps relate these instances to gamepad numbers in a way I only have to program the controls once and all the players can control their respective characters independently?

    Tagged:

  • Coming back here as I sort of figured out a way, but it has some flaws that I need help with.

    I was able to achieve most of what I wanted by taking the approach from this old post:

    construct.net/en/forum/construct-3/how-do-i-8/gamepads-two-separated-players-157869

    However, I noticed two issues:

    1. When either player 1 or player 2 dashes, both of them dash together, even though only one of them pressed the dash button

    2. The players cannot shoot at the same time. If player 2 is shooting, when player 1 holds down the shoot button (Right Trigger), player 2 stops shooting.

    I understand that must be related to the loopindex I am using. How can I avoid this from happening?

    Here's the link for the project, as I know nobody knows what I am talking about without it:

    drive.google.com/file/d/1EE8IMpcqI7_0m8bohg52_727oFNa_zjh/view

    EDIT: Run the game in debug mode and under "players", instance number 1 is going to have an instance variable called "Gamepad". Change the value of that variable to 1 in order to have player 2 working. There's a bug that sets it to 0 and I haven't figured it out yet.

    EDIT 2: Found another glitch resulted from this approach. This game has an overheat system, where shooting for too long with the Left Trigger will increase the heat level, until it reaches it's maximum, when the player cannot shoot anymore. When overheated, the heat meter gradually goes down, and the player can shoot again once it completely depletes.

    Although the gradual reduction of heat is working for Player 1, it's not for Player 2. The heat never reduces, it only increases if I hold down the Left Trigger and it stays there when I release it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You likely have a conflict in both your Overheat (which likely leads to the shooting problem), as well as with your dashCooldown variables. I'm pretty sure just by looking at your propriety sheet that you just confused one with the other at some point in the code, as it seems like you have duplicates from the parent.

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