Atribute variable to a generic object which affect subobject

  • Hi community ^^

    I'm trying to make door which can be unlocked by using a switch. Each door and switch has a color.

    I want to create a géneric collider. When the player collide with it, it open the good color door.

    I Know how to attribute variable to this object. But I don't know how to do this variable affect the doors.

    Could you help me please. :]

    Thanks for your advices

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure if I understood you correctly.

    So when player collides with red switch, you want to open the red door? On collision with blue switch, open blue door and so on?

    Add "Color" instance variable to both Switch and Door sprites. Set correct Color for each switch and door ("red", "blue", "green" etc.)

    Your code could look something like this:

    Player on collision with Switch
       Door compare instance variable Color=Switch.Color  -> Door set isOpen=1
                                                             Door set animation to "Open"
    [/code:641e481b]
  • Thanks Dop2000.

    You understood what I meant. Sorry for my poor english. ^^

    I will try it asap.

  • It works and it's very powerful. Thanks a lot Dop2000

    Finally, I used your method for my "help boxes".

    When the player collide with a generic box, the correct message is visible.

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