How do I make a gamepad event for more than one object

0 favourites
  • 3 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • I've been trying to make an "universal" event that would select an instance from a family based on the index of the gamepad. But the gamepad object seems unable to know it's own index value based on input.

    My idea was to: On something done on any gamepad; pick instance based on gamepad index value; then do something for that instance.

    However every gamepad input is required to be a predetermined index value.

    Why isn't there a general expression to know which gamepad made the input? It would make setting up multiple players 4 times more efficient.

    Unless there is a way to do this? in which case: help? D:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • really interested in this

  • One solution ( and its probably not the cleanest) - is to great a single layout that you can reuse in any game you make in the future.

    Create 4 events to handle the pressing of the start button for each game pad

    eg:

    if gamepad 0 presses start - call function "spawn player" "0"

    player.owner = 0

    if gamepad 1 presses start - call function "spawn player " "1"

    player.owner = 1

    etc.

    Then create a series of events to check which button was pressed for each controller

    eg:

    if gamepad button is down (Gamepad = 0), button = A) -> Call another function called "Shoot", "0"

    etc, and do this for every button combination.

    Once you set this up once, all you have to do is create events for each new game you create that has a function that matches the button press function call from your "input" layout.

    so. on function "shoot" "0"

    pick player.owner = function.param(0) -> do whatever should happen here

    if you did on function "shoot" "1" it would do the shoot event for player 1 instead

    I hope this all makes sense, im pretty tired right now.

    But basically you only need to setup on layout with a series of if statements to handle each gamepad and button. Have them call a generic function EG: jump, shoot etc. And pass the gamepad index number as a parameter, so that you only need to have one function per button, which will determine which player to do the action to based on the gamepad index that initiated it.

    once you set it all up once, you can simply import that layout to your next game, and include it in your main event sheet, and it will be all ready to go.

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