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

0 favourites
  • 10 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • 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?

  • 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.

  • 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

  • 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)

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • PlayerFamily on Collision ... returns a pick list. Check the PlayerFamily.count in a condition.

  • On collision would only work if they all collide at the same time.


    PlayerFamily 'is overlapping' Door


    PlayerFamily.PickedCount = PlayerFamily.Count

  • i meant .PickedCount


  • 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.

  • Yeee thanks all.

    The PickedCount is a great solution. I didn't know it but it will be very usefull for other things now.

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