How do I use families correctly

Just started using Construct 2? Post your questions here

Post » Sun Oct 02, 2016 8:29 pm

Exactly what I needed ! :)
B
7
S
2
G
1
Posts: 14
Reputation: 533

Post » Tue Oct 04, 2016 1:52 pm

I found a way to do this but it's still a bit bulky. I'll try to trim the script tomorrow but for now it still saves you the hassle of writing separate events for each player. Also it works pretty well. Left click to select player 1 and right click to select player 2. The first uses WSAD + space and the second uses the arrows and num zero. You could easily add as many players as you like provided you have enough keys for them.

https://drive.google.com/open?id=0ByMnh ... 3dnNnBtNDg

If you have questions let me know.
ImageImageImage
B
14
S
5
G
2
Posts: 22
Reputation: 2,048

Post » Tue Oct 04, 2016 8:07 pm

Hi again,
I tested on my project and it works perfectly, thx again.

BUT, 2 things are annoying me : if I follow your exemple, I need to reproduce every animation (and behavior, and condition, and...) to each player, for every character. Let's say we have 8 characters and 4 players, that means I have to copy 32 times the same code. I'm sure we could find a better way to optimize it. Besides, for each animation, I need to import again and again every frames, check that the collison polygons, and the image points are the same for each player (I didn't find a way to copy/paste an animation from an object to another).
I tryed to clone the object player1, but now it seems that the player2 (the clone) is ALSO a player1 object.

In brief, isn't it possible to think in reverse order ? I mean, create each character, and then, give them the inputs of the right player ?

(I apologize if it's going to be a little bit off topic, if I need to, I will reopen in a more appropriate part of the forum)


Edit : Thank you RageByte, I will look at your file.
Edit2 : wow, it looks very impressive and efficient. I need to take my time to understand every line :) BTW, thak you for the comments !
B
7
S
2
G
1
Posts: 14
Reputation: 533

Post » Wed Oct 05, 2016 3:15 pm

Ok, I redid most of it. It does basically the same thing in a more flexible way and less events. It should even be more CPU efficient. This new design relies on text variables and the tokenat, tokencount and find expressions to search through, parse and manipulate the text. The point is to store and access multiple variables in a single text variable for higher flexibility. It's harder to grasp but I put a lot more detailed explanations in there. Hopefully they will help but as I said, feel free to ask.

https://drive.google.com/open?id=0ByMnh ... 3dnNnBtNDg

EDIT: I accidentally used the latest Construct beta r236 for this so you'll need that to open it.
ImageImageImage
B
14
S
5
G
2
Posts: 22
Reputation: 2,048

Post » Thu Oct 06, 2016 6:58 am

Nice control scheme @RageByte with clever use of families.
ImageImage
B
105
S
46
G
23
Posts: 778
Reputation: 22,226

Post » Thu Oct 06, 2016 10:15 am

alextro wrote:Nice control scheme @RageByte with clever use of families.


Thank you :)
ImageImageImage
B
14
S
5
G
2
Posts: 22
Reputation: 2,048

Post » Thu Oct 06, 2016 9:05 pm

It works peeeerfectly !
Now I can destroy my project and start again on solid bases. I already tested with platform behavior, and now all I have to do is add a real selection menu with nice portraits :)

Thx x 1000.
B
7
S
2
G
1
Posts: 14
Reputation: 533

Post » Fri Oct 07, 2016 11:16 am

ralf5543 wrote:It works peeeerfectly !
Now I can destroy my project and start again on solid bases. I already tested with platform behavior, and now all I have to do is add a real selection menu with nice portraits :)

Thx x 1000.


You're welcome, I'm glad you can use it.
ImageImageImage
B
14
S
5
G
2
Posts: 22
Reputation: 2,048

Post » Sat Oct 08, 2016 10:26 am

Just a question : when you write
Code: Select all
Pick Player where Player.UID != Player2
(on mouse click), it prevents player1 to attribute his controls to a character already selected by player 2. But shouldn't it also prevent from attribute several times the same controls to differents characters ? To make it clear, make this event possible only if Player.UID hasn't been set yet.
I tried Pick Player where Player.UID != Player2 & Player1, but it doesn't work.
B
7
S
2
G
1
Posts: 14
Reputation: 533

Post » Sun Oct 09, 2016 5:14 pm

ralf5543 wrote:Just a question : when you write
Code: Select all
Pick Player where Player.UID != Player2
(on mouse click), it prevents player1 to attribute his controls to a character already selected by player 2. But shouldn't it also prevent from attribute several times the same controls to differents characters ? To make it clear, make this event possible only if Player.UID hasn't been set yet.
I tried Pick Player where Player.UID != Player2 & Player1, but it doesn't work.


You could simply add "if Player1 = -1" on the first Mouse Left Click event and "if Player2 = -1" on the Mouse Right Click event and that way you can't choose 2 classes for the same player. But that's a very rudimentary selection process and I didn't pay much attention to it. Here is a better way to do the whole thing, though it uses Arrays and separate layouts - one for Player selection and one for the game it's self , like in plinkie's example. This way you can also have 2 or more players with the same class. Press a button and select the class. Then press Start to go to the Game layout or Reset to start the selection again.

https://www.dropbox.com/s/6vyx7bt45op0z ... .capx?dl=0

I still haven't added controls for players 3 and 4 so selecting them will spawn players but they don't do anything. Just add the token strings with the key-codes in the Controls variable of the Blue and Yellow buttons using this format "Left | Right | Up | Down | Something". You can find a list of keys and their respective codes on the web but if you're looking to assign game-pad controls to it I have no idea how because I never used that feature.
ImageImageImage
B
14
S
5
G
2
Posts: 22
Reputation: 2,048

PreviousNext

Return to Beginner's Questions

Who is online

Users browsing this forum: FartsLolz and 3 guests