key opens door

jnica23jnica23 Member Posts: 47
edited November -1 in Working with GS (Mac)
Does anyone know how to have an actor collect a key and once that key is collected he is able to unlock a door (new level)? but until the key is collected that door(level) is locked.

Comments

  • FloridaGamesFloridaGames Member Posts: 328
    Make a boolean called key.
    When actor collides with key: change attribute game.key to true.
    When attribute key is true:
    destroy actor(door).
  • jnica23jnica23 Member Posts: 47
    how do i make a boolean? and I dont want to destroy the door I want to main actor to get the key and go to the door which is on the other side of the screen, then once the actor goes to the door he enter a new level (change scene).
  • FloridaGamesFloridaGames Member Posts: 328
    Make a new attribute(boolean). (hit the + button in attributes).
    Find the position of the door(x,y).
    When game.key = true.
    Move to (door x,y).
  • jnica23jnica23 Member Posts: 47
    this is so, frustrating... I appreciate your help and I understand what you are telling me and it actually opened my eyes to what this software is capable of but I cant get it to work.

    here is exactly what I'm trying to do, and the kind of scene I'm working with.

    the actor is a ball
    the scene is that of a labyrinth
    using the accelerometer the ball move and collects objects
    there is a door that is locked
    to unlock the door the ball must collect a key
    once the key is collected the ball can collide with the door and enter a new level
    if the ball collides with the door without collecting the key nothing happens

    I've tried to add a new attribute and make a rule where the attribute is true and add (+) the ball collides with door to change the scene but for some reason it doesnt work, the rule only recognizes [ball collide with door] and just changes the scene (the conditions are valid is on All)... its really frustrating... any advice would be greatly appreciated!
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    do this:

    make a boolean attribute called keyCollected, and have it set to false

    have a rule in the ball when the ball overlaps with the key change attribute keyCollected to true

    have a rule in the key when actor overlaps or collides with ball
    -change attribute self color alpha to 0

    then have another rule in the ball when attribute key collected is true and actor overlaps or collides with door
    -change scene
  • jnica23jnica23 Member Posts: 47
    i did that exactly how you said and still have the same result. the game is not recognizing that all conditions have to be true and I have it set to "All", as soon as i collide with the door i go into a new scene without having collected the key...
  • jnica23jnica23 Member Posts: 47
    Got it to work, problem was my attribute was false!

    Now I have another problem, once the scene changes, the ball can just go to the door and change to the next scene without collecting the new key. How do I make it so that the actor has to collect another key to access the door?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    when you change the scene you can change the keyCollected attribute back to false, or have seperate attributes for each level
  • jnica23jnica23 Member Posts: 47
    I have 25 levels, how do I go about just resetting the keyCollected back to false?
Sign In or Register to comment.