Actor has key or item to open door

butterbeanbutterbean Member Posts: 4,315
edited November -1 in Working with GS (Mac)
I was reviewing the platformer template on GS, and wanted to know, how can you tell the game that an actor has a key or some item that will allow him/her passage through a doorway, where without the key or item, they cannot pass through.

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    The keys do nothing.

    But you can always make a game attribute that counts how many keys or which key has been selected to allow gate access.

    ref: Gauntlet
  • butterbeanbutterbean Member Posts: 4,315
    So can I set a game attribute (boolean) "keyinhand" and set it to be false when the player doesn't have it, and true when the player touches it, and allow access into a doorway?

    Basically, I don't want the actor to have access to the doorway without having touched the key
  • KamazarKamazar Member Posts: 287
    If you're planning on having multiple keys/items, I'd use this solution, but ONLY if the keys are going to be found in the same order every time. Key A always has to be found before Key B, and Key C after Key B.

    Create an integer attribute called "keys" which is equal to zero
    When "actor" collides with "key A", "keys" = "keys"+1
    Destroy "key A"
    When "actor" collides with "door A"
    If "keys" = 1, open door (destroy the original door actor, and replace it with a non-collidable and immovable image of an open door)

    Do this with all the other doors by adding increments of one to the "key" attribute. If the keys can be found in a bunch of different orders, than yeah, like CodeMonkey said, just create a bunch of boolean attributes.
Sign In or Register to comment.