How to have two characters?

0 favourites
  • 8 posts
From the Asset Store
Footsteps SFX Two contains 450 sounds of steps and jumps on different surfaces.
  • Alright, So I followed Ashley's excellent platformer tutorial, and I've been using that as a basis for development. So here's my question, I have two different player characters, and you need to switch between them to solve puzzles.

    So say I have Player1's position set to PlayerBox, and when the player presses C, it stops setting Player1's position to PlayerBox and makes Player2's position set to Playerbox, and vice-versa.

    However, I don't want Player2 or Player1's position to be teleported to PlayerBox, I actually want PlayerBox to be set to their positions.

    So any idea how would I go about doing this?

    All help would be appreciated!

  • No problem ... but you have change the tutorial to improved it so we don't know anything about your new code ... share your capx using dropbox or another hosting site and give us a link to this capx and we could help you.

  • I wouldnt even bother tryin to do it that way really.

    Make the 2 chars you can control both have whatever control behavior you want and when you need to switch between them just disable input on the old one and enable input on the new one.

    Treat each as its own playable character with full support for everything your game requires

  • No problem ... but you have change the tutorial to improved it so we don't know anything about your new code ... share your capx using dropbox or another hosting site and give us a link to this capx and we could help you.

    I've added a simple attack, and the player can jump with Z now, but otherwise it's identical.

    I wouldnt even bother tryin to do it that way really.

    Make the 2 chars you can control both have whatever control behavior you want and when you need to switch between them just disable input on the old one and enable input on the new one.

    Treat each as its own playable character with full support for everything your game requires

    I thought of doing it like that(It would be much easier to do in actuality), but that would mean the player would have four jump buttons and two attack buttons, which would complicate things and make for a awkward control scheme.

    Currently I have it so the player switches between the two being visible and not visible by pressing C and V.

  • no you dont need 2 of each control. You just setup your controls to effect the currently active one and make the one thats not bein controlled ignore input

  • no you dont need 2 of each control. You just setup your controls to effect the currently active one and make the one thats not bein controlled ignore input

    Derp, I'm rather the idiot it seems. Can't believe I never thought of doing it like that.

    It worked, thank you very much!

  • The above is simpler and probably less frustrating. Alternatively you could create a global variable such as GV:"Player". Have it default set to '0'.

    GV:Player = 0 (Controls Player 1)

    When Player presses 'C', add '1' to GV:Player

    If GV:Player = 1 (Controls/Playerbox deactivated, PlayerBox set to Player 2 position).

    Then adds '1' to GV:Player

    GV:Player = 2 (Controls Player 2)

    When Player presses 'C', add '1' to GV:Player

    So if GV:Player = 3 (Controls/Playerbox deactivated, PlayerBox set to Player 1 position).

    Then adds '1' to GV:Player

    GV:Player = 4 (When GV:Player =< 4, set GV:Player = 0)

    -------

    This means to change who the Playerbox controls you only need to set the value of GV:Player box to 1 or 3 and it should automatically re-position the Playerbox as the values change to 2 or 4(Acutally 0). This has an advantage if you are wanting to put transition animations in between the player swtich. But a disadvantage if all you want is a straight switch like mentioned in a comment above.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • the easiest way to do that is :

    1)enable and disable so the events will be like these :

    make a boolean variable for each player if the boolean = yes then it will move if no it will not move.

    2)2 different keys like WASD for player1 and arrows for player2 , or you can make the touch screen buttons

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