How do I animate THEN perform action?

Hey there,

I have made an actor that spawns an enemy actor every 3 seconds. I have also drawn a few sprites to animate a trapdoor of sorts that opens and shuts. How do I get the spawn actor to animate and then spawn the enemy? I've tried a timer set to "every 3 seconds" and following that a spawn actor action, but it doesn't show the animation, or if it does, it does it very fast. I have tried using a local boolean variable to switch between animating and spawning, I think its the timers...

I'm brand new to this (3rd day playing about with GS) so apologies for the noob problem. Any suggestions are greatly appreciated :smiley:

Comments

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    Hey @Daftbomb,

    It's possible that you don't have enough frames for your animations to run well. Also, are you trying to animate open, then spawn, then animate close???

  • DaftbombDaftbomb Member Posts: 36

    Thanks for the reply. If I run the animation constantly outside a timer it works perfectly, I only use 4 different images at about 15fps but it's smooth enough for the style I'm using. The moment I move it inside a timer it doesn't work. Because of the speed of the spawn animation I'm not too fussed about a midway spawn but that'd be the icing on the cake.

    I've settled for having them animate constantly, but I'd dearly love to understand what is causing this/a solution.

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2015

    @Daftbomb said:
    How do I get the spawn actor to animate and then spawn the enemy? . . .

    I would do it like this . . . let's imagine our animation sequence is this . . . .

    Xframe001

    Xframe002

    Xframe003

    Xframe004

    Xframe005

    Xframe006

    Xframe007

    Xframe008

    Xframe009

    . . . you would run the animation as normal (with the animation behaviour) and then place the spawn behaviour in a rule that reads:

    When self.image is Xframe009 . . . then do the spawn.

  • DaftbombDaftbomb Member Posts: 36

    That's brilliant, makes so much sense. Thank you, I shall give that a go.

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited January 2015

    @Daftbomb We have a free template so you can see what Socks said in action, it also does some other cool things like cycle through the animation a set number of times before doing X.

    http://www.deepblueapps.com/animation-controller/

  • DaftbombDaftbomb Member Posts: 36

    Thank you all for your replies. That video really helped me nail it down.

    Having an animation within a timer still isn't working for me, so I've created a boolean "start spawing" set to false. Then within a timer I set it to true. The animation only runs when true, and using your suggestions of using the name of an image in rules I can set it back to false whilst spawning an enemy.

    Perfect solution, many thanks :smiley:

    Now, if only I could figure out why the first enemy I spawn won't die I'll be laughing (all others do)

Sign In or Register to comment.