How do I control several doors with different levers?

0 favourites
  • 7 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • I want to make doors open using levers that are placed either next or far from a door. I also want these to affect each other through having the same variable. For example, lever 0 controls door 0, lever 1 controls door 1 and lever 2 controls door 2. One lever might even controls two doors if they share the same value, or vice versa. So instead of making more sprites for each lever, I want to just set their values the same.

    How do I compare this in the events sheet?

    Could someone show an "example picture" or explain this to me? Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here: https://www.dropbox.com/s/g9hnzyf6tim0m ... .capx?dl=0

    It seems to work quite nicely. The first enemy opens the first door. They all have the same variable at 0 however. How did you connect the first enemy with the first door exactly? I want to be able to set the variable to the same for those to connect.

  • It seems to work quite nicely. The first enemy opens the first door. They all have the same variable at 0 however. How did you connect the first enemy with the first door exactly?

    They all start with variable at 0 so on the:

    On start of Layout | set InstVar to Self.IID

    it replaces the variable with each object's respective INSTANCE ID. You could start there or manually assign the variables.

    I like using that since it takes less work. Now it's just a matter of repositioning the enemy sprites. You can even modify the capx so instead of destroying the enemy it simply toggles a variable to open/close doors...

  • >

    > It seems to work quite nicely. The first enemy opens the first door. They all have the same variable at 0 however. How did you connect the first enemy with the first door exactly?

    >

    They all start with variable at 0 so on the:

    On start of Layout | set InstVar to Self.IID

    it replaces the variable with each object's respective INSTANCE ID. You could start there or manually assign the variables.

    I like using that since it takes less work. Now it's just a matter of repositioning the enemy sprites. You can even modify the capx so instead of destroying the enemy it simply toggles a variable to open/close doors...

    Aha, but is there no way to compare if they just have the same value to an instance variable called "type"? If they both have one and shares the number "0" for example. It would be super easy to just drag in the "lever" and the "door" and then set their instance variable's value ("type") to "0".

  • Aha, but is there no way to compare if they just have the same value to an instance variable called "type"? If they both have one and shares the number "0" for example. It would be super easy to just drag in the "lever" and the "door" and then set their instance variable's value ("type") to "0".

    Of course there is. Just create the new variable yourself. You can assign it to either the family or the objects themselves.

  • I am such an idiot. Did not think of the "compare instance variable" condition with "door.type" = "lever.type" etc.

    Many thanks though!

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