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?
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.
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.
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.
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.
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).
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.
Comments
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
Thanks for the help!
Can any one help?
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.