How to have two characters?

Get help using Construct 2

Post » Wed Jun 20, 2012 3:26 am

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!
B
5
Posts: 5
Reputation: 565

Post » Wed Jun 20, 2012 3:58 am

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.
B
16
S
5
G
3
Posts: 298
Reputation: 5,240

Post » Wed Jun 20, 2012 6:58 pm

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
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Wed Jun 20, 2012 9:02 pm

[QUOTE=naelian] 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.[/QUOTE]
I've added a simple attack, and the player can jump with Z now, but otherwise it's identical.

[QUOTE=aridale] 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[/QUOTE]
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.
B
5
Posts: 5
Reputation: 565

Post » Wed Jun 20, 2012 9:59 pm

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
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Thu Jun 21, 2012 5:59 pm

[QUOTE=aridale] 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[/QUOTE]

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!
B
5
Posts: 5
Reputation: 565

Post » Thu Jun 21, 2012 6:49 pm

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.
B
85
S
31
G
14
Posts: 106
Reputation: 16,440

Post » Thu Jun 21, 2012 7:06 pm

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
B
48
S
15
G
6
Posts: 795
Reputation: 12,035


Return to How do I....?

Who is online

Users browsing this forum: linkman2004, nickbernstein, supreme676 and 19 guests