How do I check if all instance of a family overlap an object

Get help using Construct 2

Post » Thu Mar 10, 2016 8:10 am

Hi,

I have differents isntances Player1, Player2, Player3 ....and PlayerX but they are in the same family PlayerFamily.
What i want is to open a Door whenall Players overlap the Door together.

So we can do like
- Condition : Player1 overlapping Door and Player2 overllaping Door and .... and PlayerX overlapping Door
- Action : Door open

But i'm searching more something like that:
- Condition : If all PlayerFamily overlapping Door
- Action : Door open

I have try the Condition "Pick all" but doesn't work.

Is it possible? And how?
B
18
S
7
G
1
Posts: 56
Reputation: 3,000

Post » Thu Mar 10, 2016 9:26 am

I'd love to know If there is anything like that too.

Here's my workaround:
Give door a number variable that increase by 1 each time a player passing through.
When the number equals to the total number of players then the door will open.
B
7
S
2
G
1
Posts: 42
Reputation: 1,144

Post » Thu Mar 10, 2016 10:43 am

I have something working but i'm not convinced.
So here is what i have done :
Door got variable Open=Number

- Condition : PlayerFamily on collision with Door
- Action : Door add 1 to Open

- Condition : For each PlayerFamily And PlayerFamily is not overlapping Door
- Action : Door set Open to 0

Result : If all Players are on the Door, variable Open = 1 and if only one Player s not on it then Open = 0
B
18
S
7
G
1
Posts: 56
Reputation: 3,000

Post » Thu Mar 10, 2016 11:31 am

Here's what I have in mind:

Door has variable Open (number) = 0
PlayerFamily has variable Key(number) = 1 (this to prevent one player passing door multiple times)

Condition: PlayerFamily on Collision with Door AND PlayerFamily Key = 1
Action: Set PlayerFamily Key to 0
Add 1 to Door Open

Condition: Door Open = PlayerFamily.Count
Action: make door open (your mechanic)
B
7
S
2
G
1
Posts: 42
Reputation: 1,144

Post » Thu Mar 10, 2016 3:04 pm

It doesn't work because with your condition only one need to overlap Door to open it.
This work only if there is a Key and only the player who got the Key can open the Door.
B
18
S
7
G
1
Posts: 56
Reputation: 3,000

Post » Thu Mar 10, 2016 3:34 pm

PlayerFamily on Collision ... returns a pick list. Check the PlayerFamily.count in a condition.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Mar 10, 2016 3:41 pm

On collision would only work if they all collide at the same time.
Try:
PlayerFamily 'is overlapping' Door
AND
PlayerFamily.PickedCount = PlayerFamily.Count
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198

Post » Thu Mar 10, 2016 4:18 pm

i meant .PickedCount

sorry
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Mar 10, 2016 4:34 pm

It works for me. The idea is that each Player is assigned with a variable Key = 1,
when they collide with the Door, they transfer their keys to the door
(by setting their Key=0 and add 1 to Door). When the Door has enough Keys (=Family.Count)
then it would open.

As the door only allows whoever has Key=1 so the ones that already passed
wouldnt be able to trigger the door again.
B
7
S
2
G
1
Posts: 42
Reputation: 1,144

Post » Thu Mar 10, 2016 6:23 pm

Yeee thanks all.

The PickedCount is a great solution. I didn't know it but it will be very usefull for other things now.
B
18
S
7
G
1
Posts: 56
Reputation: 3,000


Return to How do I....?

Who is online

Users browsing this forum: kurtbal and 9 guests