math question
Hi there everybody,
unfortunately i'm the one who's not so skilled in reasoning about math here, my brain can do only so much, so i'm gonna ask a new question that i'm sure many of us will have the answer ready before even getting done reading my question![:D :D](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/grin.png)
i have a BonusActor that spawns random coins into the scene when it collides with Player Actor, and the Player Actor has to get all of the spawned Coins within a certain amount of time. those the Coins have a Rule that says "when colliding with player Actor, make game.Coins = game.Coins-1"
game.Coins is an integer game.Attribute.
another Rule controls the amount of Coins spawned by BonusActor, lets say it spawned 12 coins now, so game.Coins should equal 12 into my game.Attributes.
then, when game.Coins = 0, I should get something like Level Complete! and my Player Actor should get destroyed.
all right, the problem now is that i cannot have game.Coins = 0 from the beginning, or else my game would stop before Player Actor will get all the 12 Coins spawned, so i set game.Coins = 1. in this way, after BonusActor will have spawned its 12 coins, the final value of game.Coins will be 13, not 12 anymore.
so i'll never get to game.Coins = 0, i'll always game.Coins = 1 after Player Actor will "eat" all the 12 coins into the scene...
what can i do to fix this issue?
hope my explanation is clear, and thanks again in advance, as usual![;) ;)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/wink.png)
unfortunately i'm the one who's not so skilled in reasoning about math here, my brain can do only so much, so i'm gonna ask a new question that i'm sure many of us will have the answer ready before even getting done reading my question
![:D :D](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/grin.png)
i have a BonusActor that spawns random coins into the scene when it collides with Player Actor, and the Player Actor has to get all of the spawned Coins within a certain amount of time. those the Coins have a Rule that says "when colliding with player Actor, make game.Coins = game.Coins-1"
game.Coins is an integer game.Attribute.
another Rule controls the amount of Coins spawned by BonusActor, lets say it spawned 12 coins now, so game.Coins should equal 12 into my game.Attributes.
then, when game.Coins = 0, I should get something like Level Complete! and my Player Actor should get destroyed.
all right, the problem now is that i cannot have game.Coins = 0 from the beginning, or else my game would stop before Player Actor will get all the 12 Coins spawned, so i set game.Coins = 1. in this way, after BonusActor will have spawned its 12 coins, the final value of game.Coins will be 13, not 12 anymore.
so i'll never get to game.Coins = 0, i'll always game.Coins = 1 after Player Actor will "eat" all the 12 coins into the scene...
what can i do to fix this issue?
hope my explanation is clear, and thanks again in advance, as usual
![;) ;)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/wink.png)
Best Answers
-
Braydon_SFX Posts: 9,273
Hi,
You should create an attribute called (integer) game.HowManyCoins.
Then, create an actor called Round Rules.
In that actor, put a change attribute
game.HowManyCoins to 12.
Drag that actor onto the screen where the player cannot see it.
Then, when your actor overlaps with the coins,
change attribute Game.HowManyCoins to Game.HowManyCoins-1
Then, create a rule in your round rules:
When attribute Game.HowManyCoins = 0, do whatever.
You'll need to unlock the Round Rules actor for each level to change that Game.HowManyCoins based upon how many coins are on each level.
You might need to tweak to fit your game, but this should be a solution for you.
Hope this helps.My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
-
jn2002dk Posts: 102
One way would be to have another attribute, maybe a boolean called collecting, set to true once you hit the actor that spawns coin but otherwise set to false
Then you would check for it when you check if coins=0 so that rule only apply if the boolean is true and otherwise ignored
Answers
Rule: (when all are true)
when attribute (self.Time) is > than 1
when attribute (game.coins) = 0,
Destroy this actor.
By using self.Time, you should give the actor enough time to have coins spawned before the player uses the destroy feature.
all right, i think i will have to make a boolean attribute to control the my collecting coins.