Timer
Lucamc
Member, PRO Posts: 60
Hey guys,
I would like to make a Timer that when my actor is not touching the ground the timer should start and when it is touching the ground it should not start.Let say when the actor touches the ground after three seconds and then leaves it it should start from 0 again and so on. So by now I have these rules:
Rule Attribute game.gametimer > 0 Timer every 1 Change Attribute game.gametimer to game.gametimer-1. Rule Attribute game.gametimer = 0
How can I reset the timer?
I would really appreciate your help.
Comments
You can use a ` (backtick symbol) at the start and end of a code block in order to format text that includes rules, which is what I did in your post above. It looks like this:
this is a code block
Make a boolean called game.resetTimer and set it to true. When your actor collides with the ground, change game.resetTimer to true. Have a rule that changes game.gametimer back to its initial value when game.resetTimer is true. In the otherwise section of your actor collides with ground rule, change game.resetTimer to false. Add a condition to the timer rule you already have that makes it start when game.resetTimer is false.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Create a Boolean attribute called something like Jump and set it to false,
Create a Rule
Change the rule you currently have to:
Anymore issues feel free to PM me, i'll see what I can do to help further
Developer For BLUNTentertainment - Feel Free To Message Me! - Free Beginner Templates!
@tatiang Should code block be an integer or boolean?
A code block is just a formatting tool for the forums. It has nothing to do with GameSalad. I just mentioned it because if you type this directly into the body of a message:
Rule
Attribute game.gametimer > 0
Timer every 1
Change Attribute game.gametimer to game.gametimer-1.
Rule
Attribute game.gametimer = 0
It's quite confusing to look at, whereas if you use a codeblock by including backticks, it looks like this:
Rule Attribute game.gametimer > 0 Timer every 1 Change Attribute game.gametimer to game.gametimer-1. Rule Attribute game.gametimer = 0
I like to use code blocks and indent as well:
When attribute game.gametimer > 0 Timer every 1 Change Attribute game.gametimer to game.gametimer-1. When attribute game.gametimer = 0 .....
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I have copied everything expect I am not shore how to put these following sentences in behaviours.
Have a rule that changes game.gametimer back to its initial value when game.resetTimer is true. Add a condition to the timer rule you already have that makes it start when game.resetTimer is false.
Could you put it in a code box?
Thanks
When attribute game.resetTimer is true Change attribute game.gametimer to 50
I have no idea what you're starting at so change the 50 to whatever it should be.
When attribute game.resetTimer is false AND attribute game.gametimer > 0 Timer every 1 second Change Attribute game.gametimer to game.gametimer-1.
The 'AND' is created by changing the rule from 'any' conditions to 'all' conditions are true. 'All' is the default.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User