Timer not updating with changing attribute

BluSpyderBluSpyder Member Posts: 129
edited February 2012 in Working with GS (Mac)
I have an actor that spawns every certain amount of time. I have about 10 of them in the scene so that the spawn is everywhere.

I have my spawners as: every -> game.difficulty (real attribute) -> Spawn actor

And have another actor on the scene changing the game.difficulty to game.difficulty-0.5 every 2 seconds.

The spawners times are not updating. They continue to spawn at the starting number of the difficulty attribute. I have a text display to show the difficulty attribute to make sure it is changing every 2 seconds and it is.

So why aren't my spawner actors spawning at the changing attribute?

Comments

  • BluSpyderBluSpyder Member Posts: 129
    edited February 2012
    @tshirtbooth Alright, thanks for the reply. And I think that's stupid it's not fixed, is there a reason they won't fix it or have they just not gotten to it? Or are they even aware at all?

    I actually already tried what you suggested, but it doesn't seem to work. Once the game.? transitions to the next rule, my spawning looks like it duplicates, as if the previous rule hasn't been shut down.

    But also, I did:
    if game.? is > 1 and < 1.5 (also tried < or equal to)
    every 1 second
    spawn

    and so on....

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    Hi @Wingology

    timers and an attribute for the time don't get along sometimes....(theres a problem as well with random and your values because random only accepts whole numbers)

    A way around it is (I think this is the way, off the top of my head, it's something like this I worked out a while back):

    When DifSwitch is false (--- this is a boolean att. switch)
    Change DifSwitch to true

    When DifSwitch is true
    Change Attribute Difficulty to random(1,4)
    If Difficulty is 1
    Change attribute Difficulty to .5
    otherwise
    if difficulty is 2
    Change attribute Difficulty to 1 ---- etc

    Timer: For game.difficulty seconds
    spawn actor
    Change attribute DifSwitch to false

    hope that helps out.

    Edit: beaten by TSB! :-)

    ----------------------------------------------------------------------------
    iPad app: End of the Earth –•– http://davidgriffinapps.co.uk/
    ----------------------------------------------------------------------------

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BluSpyderBluSpyder Member Posts: 129
    Sorry, I guess I don't really understand how this works. It looks like you're saying to randomize the spawning time, but that's not what I'm looking for. Or is that not what it's doing?

    Also, I thought you said timers don't work with attribute times, but it's what you have in your example?

    Sorry if I'm completely oblivious to what's going on here lol.
  • BluSpyderBluSpyder Member Posts: 129
    edited February 2012
    @gyroscope Tried entering your suggestion as well. Did not work, unless you have 2 different difficulty attributes going on here or something. I hit preview and it spawns once and then everything stops.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    Sorry, @Wingology, I misread that part in your post: "And have another actor on the scene changing the game.difficulty to game.difficulty-0.5 every 2 seconds"

    So now you're saying that they spawn faster and faster by .5 second less each time? OK, if I've understood correctly this time ;-) :

    When DifSwitch is false (--- this is a boolean att. switch)
    Change DifSwitch to true

    When DifSwitch is true
    Change Attribute Difficulty to Difficulty - .5

    Timer: After game.difficulty seconds
    spawn actor
    Change attribute DifSwitch to false

    I think that's right now, fingers crossed...

    Edit: no, it's still wrong... I can do this, honest! I did something similar a while back; give me a couple of minutes to think about it...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    Hang on, can I understand something here; if you're changing the difficulty -which is a time value you want - every 2 seconds, no matter what the value of Difficulty is, it'll still spawn every 2 seconds....

    Edit: so what you're asking for is "Spawn, every 2 seconds, but every certain value minus 0.5 seconds at the same time" ;-)

    So get rid of the every 2 seconds, I'd suggest, and spawn every game. or scene.Difficulty...

    i'll be back... ;-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BluSpyderBluSpyder Member Posts: 129
    @gyroscope I should have mentioned before also that the starting spawn rate is every 2 seconds. And yes, after time i want the difficulty to increase so the spawn rate is faster.

    I entered your new suggestion. But this still doesn't work. I think it might be because the part where it is changing by -.5 is happening so rapidly that game.difficulty goes from 2 to 0 in like a split second. Do you think placing another timer in one of your attributes might help? Like When switching DifSwitch to true, placing like this:

    When DifSwitch is false
    AFTER 1 second change DifSwitch to true

    ?


    (i appreciate you working with me)
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    So if you agree that's what your after, then my last suggestion should work, except put the first spawn outside of the "equation" as it were:

    spawn actor (----another boolean trigger perhaps needed to start this off when you want if its not immediate)
    When DifSwitch is false (--- this is a boolean att. switch, set to its default value of false)
    Change DifSwitch to true

    When DifSwitch is true
    Change Attribute Difficulty to Difficulty - .5

    Timer: After game.difficulty seconds
    spawn actor
    Change attribute DifSwitch to false

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    Hi, I was writing at the same time: surely if you want your actors spawning every Difficulty - 0.5 seconds, that's the variable time you want them spawn, and not every 2 seconds?

    If you just wanted them to spawn every two seconds that'll be Every 2 seconds, spawn, surely... or I'm still missing something here...

    Edit: maybe try putting the initial value of Difficulty higher to something like 5 seconds, then you'll see it in action better, i.e spawning at 5, then 4.5, then 4 seconds, etc.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BluSpyderBluSpyder Member Posts: 129
    edited February 2012
    Haha ok ill try to explain this better.

    At the start of the game, my spawners should spawn an actor every game.difficulty (2 seconds is the start).

    But as time goes by I want that rate to go faster. So say every 3 seconds, the attribute (game.difficulty) should decrease from 2 seconds to 1.9 seconds.
    So every 3 seconds -> change game.difficulty to game.difficulty-0.1
  • BluSpyderBluSpyder Member Posts: 129
    In this method:

    When DifSwitch is false (--- this is a boolean att. switch, set to its default value of false)
    Change DifSwitch to true

    When DifSwitch is true
    Change Attribute Difficulty to Difficulty - .5

    Timer: After game.difficulty seconds
    spawn actor
    Change attribute DifSwitch to false


    Is the timer INSIDE the (DifSwitch is true) equation?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    Ah, I see, OK, so you want a spawned actor after 2 seconds, then every 3 seconds, reduce the spawning difficulty time by .5 second; but how can that be?

    After 2 seconds: spawn
    For 3 seconds : spawn after 2 seconds minus .1 second.
    After 3 seconds: spawn after 1.9 minus .1 seconds. It still doesn't make sense to me, I'm sorry...

    Perhaps you mean to start the spawning at three seconds - i.e have game.difficulty set to 3 (seconds), spawn, then after 2.9 seconds, spawn, then after 2.8 seconds, spawn, etc? (Or have game.difficulty set to 2 (seconds), spawn, then after 1.9 seconds, spawn, then after 1.8 seconds, spawn, etc?)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    Hi again,@Wingnology

    "Is the timer INSIDE the (DifSwitch is true) equation?"

    Yes, it is, sorry, a bit clearer: make Difficulty 3 or 2, depending on the start time in seconds you require.

    spawn actor (----another boolean trigger perhaps needed to start this off when you want if its not immediate)

    When DifSwitch is false (--- this is a boolean att. switch, set to its default value of false)
    Change DifSwitch to true

    When DifSwitch is true
    Change Attribute Difficulty to Difficulty - 0.1
    Timer: After game.difficulty seconds
    spawn actor
    Change attribute DifSwitch to false

    So what happens here is it will spawn an actor, then a loop is set up: 2.9 seconds later (if game.Difficulty is set to 3) spawn another actor, then 2.8 seconds after spawn another, then after 2.7 seconds spawn another, etc.

    You'll probably need a "stopper", either with a value of max. amount of spawns, or a time stop. So if it's a time stop, it's now:


    spawn actor (----another boolean trigger perhaps needed to start this off when you want if its not immediate)

    When DifSwitch is false (--- this is a boolean att. switch, set to its default value of false)
    Change DifSwitch to true

    When DifSwitch is true
    ANd when Difficulty > 0
    Change Attribute Difficulty to Difficulty - 0.1
    Timer: After game.difficulty seconds
    spawn actor
    Change attribute DifSwitch to false

    I guess though you'd want to stop it looping well before Diificulty +.1, so perhaps stop it at a higher time setting.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BluSpyderBluSpyder Member Posts: 129
    edited February 2012
    @gyroscope Hey sorry, I had to leave for work.

    I tried your equation again, also tried with and without stopper. The spawning still doesn't work. It will spawn the first spawn that is outside of the timer, and then it will do one more spawn and then everything stops. Any idea why?


    Ed: Also, I still display the difficulty attribute in text on the scene just to see if it's working. Right at the beginning of the scene, it jumps down 1. So if i set the starting difficulty to 3, it starts on 2, it does it so fast you can't even see it change..
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    Hi again @Wingnology,

    Your first question: if your x and y coordinates in the spawn behaviour are fixed values, then they will be spawning but all in the same place.... because they appear one on top of the other, you wouldn't be seeing them individually. Perhaps put random(64,960) in the x loc. and random(64,704) in they loc.; or whatever numbers you like in the rules of the actor to be spawned in the scene, minimum and maximum places.

    2nd question answer: if you're starting difficulty value is 3 and it spawns at 2 seconds, I'm guessing it's because you've put a 1 instead of 0.1, in the line:

    Change Attribute Difficulty to Difficulty - 0.1

    Hope it sorts it for you.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BluSpyderBluSpyder Member Posts: 129
    edited February 2012
    My x and y values are correct though, spawning 0,0 relative to actor. And the actors being spawned have a moving attribute to cross the screen. So if actors were being spawned I should see them.

    I checked the value, it's still at -0.1.


    I have sort of fixed my issue with a different and junky method. I changed my spawners on my scene to spawn a spawner when difficulty reaches a certain value. ie when difficulty = 1.5, current spawner is destroyed and next spawner is spawned that has a faster rate of spawning actors. It's really confusing to explain lol. I really don't like this method though, in fact I may just trash the game as it seems unsolvable.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    I'll make a small game file for you some time today/tonight if you want (it's 4.45pm UK time here at the moment - I don't know where you are in the world!) so maybe in a couple or three hours time I'll find time to get that done for you. One last shot before you trash your game... :-)

    ----------------------------------------------------------------------------
    iPad app: End of the Earth –•– http://davidgriffinapps.co.uk/
    ----------------------------------------------------------------------------

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BluSpyderBluSpyder Member Posts: 129
    Haha ok. I'm in US, it's 10:45am at the time of your post. Thanks for sticking around to help ;)
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    You're welcome! OK, couple to three hours time then...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    OK, this was bugging me to solve again; I've changed my suggestion a bit in the game file as the "top of my head" one wasn't quite right; hoping it's the sort of thing you're after, that you can amend to your own requirements (sorry it was a bit later than I said!):

    http://dl.dropbox.com/u/14060718/DG spawn faster test.gameproj.zip

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BluSpyderBluSpyder Member Posts: 129
    Ah perfect. I got it to work now. I think it was the timer for changing the switch to false that I wasn't doing right. Thanks so much for doing that for me.
  • youdvdkyoudvdk Member, PRO Posts: 21

    Hey.
    @gyroscope‌
    Would you be able to make that dropbox file available again? I am having the same problem :)

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

    @youdvdk I don't have that demo file but I can suggest a demo I made that allows you to create a variable timer that changes with the value of an attribute: http://forums.gamesalad.com/discussion/comment/464547/#Comment_464547

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

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited September 2014

    Hi @youdvdk Hopefully the file from @tatiang will be useful too...

    Here's the file I made over 2 years ago now.... frightening where time goes.... :s :D

    Hope you find it useful.


    P.S Hi guys - been away for a couple of months.... not given up on GSC, just been "spinning other plates"... any excitements happened that I missed? :wink:

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • youdvdkyoudvdk Member, PRO Posts: 21

    Thanks guys. I'll try those out and see if it works!

  • NKBDLNKBDL Member, PRO Posts: 100

    Is Gamesalad gonna fix this bug?

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276

    @louisng_nk said:
    Is Gamesalad gonna fix this bug?

    It's not really a bug. That's how it's supposed to work.

    Mental Donkey Games
    Website - Facebook - Twitter

  • SocksSocks London, UK.Member Posts: 12,822

    @NipaDidIt said:
    It's not really a bug. That's how it's supposed to work.

    +1

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

    @NipaDidIt said:
    It's not really a bug. That's how it's supposed to work.

    Right. And if you think about how that behavior might work, let's say you set the value of the duration to 5 seconds... the behavior starts and waits until 5 seconds have elapsed and then resets the duration again to 5 seconds. This goes on and on. But, wait, I want to use a variable! So I decide to make the duration self.timerDuration. And I set it to 5. So the behavior starts and waits until 5 seconds have elapsed and then resets the duration again to 5 seconds. But at some point during those 5 seconds, I decide to change self.timerDuration to 9. So... does the timer start over and wait for 9 seconds right at that point even though the last cycle didn't get a chance to complete? Or does the timer add time to get up to 9 seconds and wait for that to expire?

    I imagine that the reason the (Every ___ seconds) Timer behavior works the way it does is because there isn't really a great answer to those two questions.

    Besides, my demo posted above allows you to create a variable timer and it's not that hard to do. :)

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

Sign In or Register to comment.