Using a random timer for animation

So I feel like I'm missing something simple here but I'm trying to have an actor animate randomly. This is what I have set up:

Every random(3,7) seconds
Animate

It seems pretty straight forward but when I run the preview it doesn't animate. I tried it with just a set number of seconds, such as 2, and it the actor still doesn't animate. If I make it say After 2 seconds, or take the animation out of the timer, it works just fine but only plays once. What am I missing here? Thanks.

Comments

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

    @tonymc118 said:
    So I feel like I'm missing something simple here but I'm trying to have an actor animate randomly. This is what I have set up:

    Every random(3,7) seconds
    Animate

    An 'Every' timer uses just one value for its 'Every'.

    So, if you throw at it a random range of 3 to 7 and it chooses 6, then it will do its action every 6 seconds as long as it is running.

    @tonymc118 said:
    It seems pretty straight forward but when I run the preview it doesn't animate. I tried it with just a set number of seconds, such as 2, and it the actor still doesn't animate.

    How long did you watch the preview for ? You need to wait 2 seconds (or whatever value you have) for the first action to trigger.

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

    @Socks I was able to re-create this issue by placing an Animate behavior inside of a Timer behavior. The animation doesn't appear at all.

    If I use a custom timer (game.Time ≥ game.timeStamp + random(3,7) it works.

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

  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2014

    @tatiang said:
    Socks I was able to re-create this issue by placing an Animate behavior inside of a Timer behavior. The animation doesn't appear at all.

    If I use a custom timer (game.Time ≥ game.timeStamp + random(3,7) it works.

    Weird ? You are completely right, I'd not come across that before, like you say it simply doesn't work ! A bug.

    A solution is to stick the animation into a After 0 seconds timer - then stick all that into your normal timer.

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

    I meant to post a demo file this morning but I was having Internet connection issues. Here's that demo file with the two approaches for what it's worth.

    A solution is to stick the animation into a After 0 seconds timer - then stick all that into your normal timer.

    Great find! I also had to check "Run to completion" on the After 0 seconds timer to get that to work.

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

  • floatingwoofloatingwoo Los Angeles, Calif.Member Posts: 393

    So would this be a good way to have a character do random stuff like blink or wipe his nose while he's in an idle position, Waiting for the user to make a move?

  • tonymc118tonymc118 Member Posts: 6

    @tatiang Thanks a ton, the demo file was very helpful and my animation is working how it should now. I thought it was strange too that the animation doesn't do anything inside of the timer.

    @floatingwoo‌ Yeah, this could definitely be used for that. I'm using it for a storm cloud to randomly have a lightning effect.

Sign In or Register to comment.