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

Get help using Construct 2

Post » Tue Dec 22, 2015 1:25 pm

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.
B
5
S
1
Posts: 17
Reputation: 361

Post » Tue Dec 22, 2015 1:31 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Dec 22, 2015 1:46 pm

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?
B
5
S
1
Posts: 17
Reputation: 361

Post » Tue Dec 22, 2015 2:02 pm

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Dec 22, 2015 2:07 pm

ArtChan wrote: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.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
86
Posts: 5,480
Reputation: 59,746

Post » Tue Dec 22, 2015 2:16 pm

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!
B
5
S
1
Posts: 17
Reputation: 361


Return to How do I....?

Who is online

Users browsing this forum: OddConfection and 10 guests