Keys, locks and doors

Anyone know how to make a door unlock and open after getting a key ?

Use a boolean property to keep trck of whether or not you have the key. Set up the property so that it will read TRUE after the key is collected. Set up the door so that it will not open unless the property is true. If you need any more help let me know.

A demo would be nice :smiley:

I’ll see what I can do. In the meantime:

Key has these logicbricks:
Collision with (player property)->AND->Message (havekey), Edit Object (end object)

Door has this property:[boolean] “key” set it on False.

Door has these logic bricks:
Message (havekey) ->AND-> Property (Assign property “key” value True)

Collision with (player property) + property “key”=TRUE ->AND->Ipo (this is your door opening animation)

Just a recap of what happens here: When the player touches the key, it sends the message “havekey” and then annihilates itself. The door receives the message and sets a property (which it uses to see if you’ve found the key yet) to TRUE. If the player hits the door after this property is TRUE, the door opens.

Thanks, I see if I could put those in.

What about the “To: Subject: and T/P” in the message ?

I was with you till "Collision with (player property) + property “key”=TRUE ->AND->Ipo (this is your door opening animation) "

Messages are actually very easy to use. Just type the message you want to send into the Subject field and leave everything else alone.

Add a property to your player character called “player”

Now in the door are these logic bricks:
Collision (put “player” into the field) + property “key”=TRUE ->AND->Ipo

The Ipo actuator will make the door open when the player hits it and “key” equals TRUE. If you haven’t already, you need to make an animation of the door opening, and enter its values into the Ipo actuator (at which frame the door starts to open, and at which frame it stops opening.)

If the player hits the door after “key” is set to TRUE, the door will open.

IIIII think I just send it, so you can see where I’m confuse.

Set up the door buttons like this:

Set up the key buttons like this:

It works !!! Thanks.

Try to understand why it works, too. Once you’ve learned how to use properties, you can do almost anything with logic bricks.

Cool, but don’t relax yet, still need your help with the ghost, if I put it on a different layer and use a empty to add them, it lags a big deal, why ?

I don’t know. :wink: Make sure you’re not adding too many at once.

This happens with just one item, namely, the ghost.

No answer ?

Oh, this is great! I’ve never understood the logic bricks covered here. Thanks, Plantperson!