Need help with a Rule.

QorrelQorrel Member Posts: 22
edited November -1 in Working with GS (Mac)
Im trying to make apart of my game where i have 2 actors that touch 2 goals (one actor) to change the scence but I cant seem to make it work. Any suggestions?

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    create two boolean game attributes (game.Goal1 and game.Goal2)

    Rule - when overlaps with goal1 change game.goal1 to 1
    Rule - when overlaps with goal2 change game.goal2 to 1

    Rule - when game.goal1 is true
    ------Rule - when game.goal2 is true
    -----------change scene
  • QorrelQorrel Member Posts: 22
    For some reason this does not work, Or i am more likely doing it wrong -.-
  • vegasmike1vegasmike1 Member Posts: 192
    that code works fine, you just set two game variables, make them boolean, when one actor touches a goal or something turn that associated variable to false and then have a control actor that watches the scene and a rule if xyz is false, then change scene. It really is that easy.
  • QorrelQorrel Member Posts: 22
    Tried doing it again this morning, I was doing it wrong -.-

    Thanks for the help! :)
  • QorrelQorrel Member Posts: 22
    Sorry to Bump this, Though only 2 days. I find that once it has changed scene the player cannot go back and play that scene again. I have tried making another actor to change the Values of the Boolean back to zero but that didnt work, I also tried reseting the scence after the scene change, which also did not work.

    Can any one help?
  • RHRH Member Posts: 1,079
    A boolean doesn't have numerical values, it is either true or false. That's probably where you are going wrong (I don't know if GS will automatically correct this).

    Here is what I would do:

    create attribute game.goal (integer)

    RULE:
    `
    when actor overlaps or collides with actor of type goal
    change attribute game.goal to game.goal+1
    `
    NEW RULE:
    `
    when game.goal = 2
    change scene ....
    change attribute game.goal to 0
    `
    This will make it re-playable.
  • QorrelQorrel Member Posts: 22
    RH said:
    A boolean doesn't have numerical values, it is either true or false. That's probably where you are going wrong (I don't know if GS will automatically correct this).

    Here is what I would do:

    create attribute game.goal (integer)

    RULE:
    `
    when actor overlaps or collides with actor of type goal
    change attribute game.goal to game.goal+1
    `
    NEW RULE:
    `
    when game.goal = 2
    change scene ....
    change attribute game.goal to 0
    `
    This will make it re-playable.

    Thanks = )
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I reset booleans all the time and all my levels are replayable (I know this as I am really bad at playing games so during testing it usually takes me many tries to beat my own levels!). Reset scene does nothing to attributes - it only puts actors back in their starting positions. I usually have a scene rules actor that I put as the bottom most actor in the bottom layer and put all my change attribute behaviors to reset things in this invisible non-movable actor (it seems that making this the lowest actor in the layers list makes a difference for some reason). Booleans can use 1 and 0 to mean true and false, but I don't think you can do math with them. In other words you can't have 1-1=false (if you catch my drift).
  • RHRH Member Posts: 1,079
    Ahh, that's handy to know about booleans. (although it is actually rather useless :D)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Booleans are very useful (I probably use them more than anything else). If I want to "switch on" a set of rules at certain times I use a boolean. Because booleans have only two possible values (0,1) they are the least processor/memory intensive of all the attribute types.
Sign In or Register to comment.