timer programming problem or bug?

pranshudhungana21pranshudhungana21 Member, PRO Posts: 20
edited May 2016 in Help Wanted

Hello there recently when i have been testing my prototype (started making it yesterday) i have encountered a problem with the timer because even though i say every 4 secs after every 8 sec it stop working and the time is way too long.I have post the game down below hopefully you could help

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    The only timer I see is in your Spawner actor:

    Every 2 seconds
         Change attribute self.obstacle spawner to random(1,2)

    And then you have rules to check the value of self.obstacle. The problem is that GameSalad rules only trigger when their status changes from false to true. So the rule checking to see if self.obstacle spawner = 1 will trigger when that attribute changes value from 0 to 1. And it will also trigger when that attribute changes value from 2 to 1. But it will NOT trigger when the attribute remains at 1. So if your random value repeats, the rule won't trigger:

    0
    1 trigger
    2 trigger
    2
    2
    1 trigger
    1
    2 trigger

    I have a demo that shows one way of avoiding this problem:

    http://forums.gamesalad.com/discussion/comment/513319/#Comment_513319

    Note that it was made with Mac Creator so you may need to Google convert mac creator to windows GameSalad assuming you're using a PC.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • pranshudhungana21pranshudhungana21 Member, PRO Posts: 20

    what kind of trigger should i use i am a bit confused can use a timer trigger?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Did you check out the demo file I posted a link to?

    The problem is that rules won't trigger/fire when their status doesn't change. So you have to reset the attribute value at some point so that the rule can again trigger. So instead of the list of examples I posted above, it would work this way:

    0
    1 trigger
    0
    2 trigger
    0
    2 trigger
    0
    2 trigger
    0
    1 trigger
    0
    1 trigger
    0
    2 trigger
    0
    ...

    Check out the demo!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • pranshudhungana21pranshudhungana21 Member, PRO Posts: 20

    Also when i looked at your demo i couldn't really see a difference and even after i copied your spawn table it didn't work for me i am confused? Is it because i spawned more than 1 actor for either 1 or 2 ?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    The difference is that I reset (change) the value of the attribute each time the timer runs:

    If it's not working for you, post a screenshot of your rules or post your project file.

    I'm not sure what you mean by "spawn table." My demo did not contain spawn behavior or tables at all. It's really just a simple timer, change attribute, and rules for each possible value of the attribute.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • pranshudhungana21pranshudhungana21 Member, PRO Posts: 20

    oh ok finally i did it sorry i guess because of the mac version in windows doesnt show some of the code . I just found out.Thank you taitang

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited May 2016

    Oh, sorry, I wasn't aware of that. I guess screenshots are a necessity sometimes. And you're welcome!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.