How do I open a door only after getting the key?

1 favourites
  • 6 posts
From the Asset Store
10 Orchestral Soundtracks / ~2 mins each / 11 audio clips in total
  • Hello to everyone! Im new to Construct 2 so I need a bit of time to understand better this magnific engine!

    Im creating a small platform, and I created a key and a door. When I touch the key I destroy it, but I want to be able to open the door only after "getting" the key, I did something like:

    Player on the collision on KEY > Destroy the Key

    ---> Player on the collision on DOOR > Restart Layout

    The second event I CANT create it because the method "COLLISION ON ANOTHER OBJECT" doesnt exist if I create it like a SUB EVENT... can someone help me?

    Sorry if I wasnt very clear.

  • Maybe you could give the player a boolean instance variable?

    Let's call it GotKey and set it to false

    Player on collision with key

    Player set boolean Gotkey to true

    Key destroy

    Player on collision with door

    Player is boolean GotKey

    Restart layout

    So when the p[layer collides with the door, it will only restart the layout if the boolean GotKey is true..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi again Little Stain! Thanks for replying me again!

    Your reply have a perfect logic, so I tried to apply it! The first part I did in the way you said, but the second one I can't understand how to make that happen in C2, in the Variables events there are nothing such as "check boolean"... am I wrong?

  • The condition is:

    Is boolean instance variable set

    • Test if one of the object's boolean instance variables is set to true. Invert the condition to test if false.

    This should be a condition on the object that has the boolean instance variable.

  • Hi again Little Stain! Thanks for replying me again!

    Your reply have a perfect logic, so I tried to apply it! The first part I did in the way you said, but the second one I can't understand how to make that happen in C2, in the Variables events there are nothing such as "check boolean"... am I wrong?

    This is very basic stuff, that you should know if you've read the manual and done a few tutorials.

    Have you given your player a Boolean variable?

    If so, then adding the condition LittleStain suggests should be as simple as:

    Click on Add Condition, Select Player, select 'Is Instance variable Set', and select the GotKey Boolean. Add the Door collision check as another condition, and you should then be OK to set whatever Actions you need.

  • Now I understood and now its working!! Thanks a lot guys for your time to reply me, even I'm asking this basic stuff... I'm sorry if you think that I wasted a bit of your time, and yes, maybe I should read better the manual, but Im not that type of person, I love learning through the practice, and when im stuck I can't find that specific solution on manuals... im not very patient... thanks again for your time!

    Have a nice day!

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