Handle multiple players with different controllers on same client.

0 favourites
  • 2 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • Trying to do a couch party game, with up to 3 players. Should be able to use keyboard and gamepads dynamically. I'm looking for a tutorial to do this in a smart and flexible way.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are several ways to organize this.

    For example, if all players are instances of the same sprite or family, you can store control type in an instance variable. Then, in keyboard/gamepad events pick the player instance:

    Keyboard On Space pressed
    Players controlType="kbd" : Player simulate jump
    
    Gamepad 0 on A pressed
    Players controlType="gamepad1" : Player simulate jump
    
    Gamepad 1 on A pressed
    Players compare variable controlType="gamepad2" : Player simulate jump
    

    To optimize this code you can create functions or custom actions for each movement - PlayerMoveLeft, PlayerMoveRight, PlayerJump etc. Then call these functions/custom_actions from keyboard and controller events:

    Keyboard On Space pressed
    Players controlType="kbd" : Player Jump
    
    Gamepad 0 on A pressed 
    Players controlType="gamepad1" : Player Jump
    
    Gamepad 1 on A pressed 
    Players controlType="gamepad1" : Player Jump
    
    Player Custom Action Jump 
     Player simulate jump
     Player set "jump" animation
    
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)