How do I open several doors with multiple buttons by using families ?

0 favourites
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hello everyone ! First, I'm french so I'm sorry if I do language mistakes. ^^

    I hope you'll be able to help me.

    My game : DOWNLOAD file.c3p

    There are two characters, They can run, jump and you can swap control by pressing "down". They can stand on buttons in order to activate doors which have the same color than the activated button(s). If no button of a color is activated, all the doors of the same color are deactivated too and they go back to their initial position. Simple, right ?

    Here is my problem :

    I would like to use the same script bricks for the buttons behavior and for the doors movements. It's OK for the buttons but for the doors I tried multiple things and it doesn't work, I think that I missed something to make it work properly.

    I would like to create situations in which the two characters are at the same time on different buttons to activate different colored doors.

    Thanks a lot for reading and I can't wait to read your comments on this issue.

  • I would use family instance variables and compare them. If a switch has variable 2 then it opens door 2 etc

  • Doors have a family instance variable (text) which is the color. A blue door has this variable setted on blue, a cyan door has the variable setted on cyan and so on...

    Buttons also have a family instance variable (text) which is empty until a characters activates it.

    When a character is on a blue button, the variable of the button becomes blue. If the button is of another color, the variable becomes of this color.

    So, I tried to open the doors with this condition :

    But as you can see in the .c3p file, it only opens some of the doors of the same color, not all of them as I would like.

  • In the current version (that you can download in the first message of this topic), characters can open doors which are of the same color of the activated button. It works with the blue buttons or the cyan ones.

    But the problem is that there are some... conflicts I think... when the two characters are at the same time on buttons of different colors. And I really don't know how to fix that. And I think when it will be fixed, my problem will be solved.

    Thank you if you have any idea to propose ! :)

  • The picking is kind of off in places and it's hard to determine. The event starts with if door colour = button colour, which button? which door? For gameplay like this I would give the button some variable to enable when pressed, when pressed you pick all doors that match the colour variable of the button. In this way you can have 2 buttons pressed at once. When a player releases then you set it to disabled, all matching doors will close.

  • Thank you for your answer.

    I don't know if you checked the last version of the .c3p file but I think this is what I've done in my "GPE " event sheet.

    The event is :

    - If a button is playing "ON" animation (if it is pressed)

    - - Pick doors(family) where instance variable color is equal to buttons instance variable color

    And it works but only if no other buttons of another color is pressed. This is the problem.

  • Right I see so you fixed the earlier problem. The issue here is that you need to say 'for each buttons' but I don't understand the use of the Else and the picking in the bottom half. Using 'for each buttons' should check each one that is enabled though. I see the second half is under an Else and not indented under pick doors by colour so not sure what the use of that is but you know how your game works so try and get it to work with a for each.

  • To be honest, I really don't know how to use the "For each" event. :/

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had some free time so took a proper look, it's harder than you think to get this working but I put in a fix which should give more control : dropbox.com/s/vbfbag7lud4f6re/labescape1.c3p

  • Thnak you for your time on it but there is something which doesn't work in what you did : I cannot press two different buttons at the same time. But I see how you used "For each", thank you.

    My problem is still here. ^^"

  • You can press 2 at the same time, that's what I fixed

  • I mean, if I put the two characters on buttons of the same color, it behave weirdly.

    I hope this time, the image will be displayed :

    But 'ill check if I can adapt it ! thanks !

  • Well if that's possible then you need more logic like counting how many players are pressing the same button

  • I'm not sure what exactly you are trying to achieve.

    I took the first version you posted and fixed the logic you had there.

    File made in beta R216

    It seems to open all doors of a same color, as long as character is pressing the button to the opposite side.

    Is that what you wanted to achieve ?

  • I cannot open your link.

    What I try to achieve is :

    As long as at least one button of a color is pressed, all the doors of the same color are activated. The doors stay activated until no more of these buttons are pressed.

    Because there are two characters, two different colors can be activated at the same time.

    And I would like to use only families events to avoid to copy/paste the behaviors for all of the differents colors I'll have in my game.

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