[Feature Request]Duration of Animation

0 favourites
  • 9 posts
From the Asset Store
Ninja char for your game! Make your own Shinobi game with this art.
  • This is the trouble I've been having: scirra.com/forum/topic66077.html

    It's all around coming up with ways to just tell Construct 2 to play a looping animation for a set amount of time and then do something.

    But because the animation is never 'finished', the event trigger On Animation Finished cannot be used. So the event trigger Is Playing is used. Which then seems to cause it to go into an eternal loop because the animation is always 'Is Playing', and using system wait doesn't seem to stop it and make it go to the next action.

    I've tried using various plugins and behaviors from Rex, but none work.

    I just would like a native Duration feature that can be called in the event sheet that works correctly with looping/ping-pong animations.

  • A looping animation has an infinite duration, so how does that help?

    Animation speeds are in frames per second, so as long as you don't change the individual frame times, the duration for playing through once is number of frames / animation speed. E.g. 10 frames at 5 frames per second = 10 / 5 = 2 seconds duration.

  • I set a looping animation for something like an idle animation. The idea is to have the sprite play it for a set amount of time that can be controlled by the event sheet.

    For example, you have a head swaying idle animation. It's on a loop/ping-pong. Assume you already don't care about clipping or made it so it doesn't matter.

    You set up an event to have that animation play for random(4) seconds or something similar.

    Therefore, the duration of that idle animation lasts for a random amount of time each time that animation would play.

    Basically, I don't care about the full length of the animation at all, because it was made to repeat and be clipped. I just want to control how long it stays on-screen regardless of its own length.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • On top of my head: each animation has frame numbers. What about instead of random time, you get a random repeat number and then a random frame number. Then count each animation loop and increase them until they reach your target?

    For example: get a random repeat number between 2 and 4. (say you got 4)

    Then get a random frame number between 0 and 12 (say you get 8)

    also get current repeat global variable.

    increase current repeat every time animation plays 8

    then have a condition that checks current repeat = randomly got repeat number (for our example it was 4) and if true, stop the animation or do sth else.

    I hope I could explain it, English is not my main.

    Regards;

  • It's all around coming up with ways to just tell Construct 2 to play a looping animation for a set amount of time and then do something.

    You could achieve this pretty easily with timer variable of your own.

    Create instance variables idleDuration and animationTimer for your sprite.

    Then do events something like this:

    every tick

    ..add dt to sprite.animationTimer

    on animation 'Idle' started

    .. set animationTimer to 0

    animationTimer > idleDuration

    .. animation 'Idle' is playing

    .... do the stuff you want to do at the end of your idle animation

  • Well the animation editor has a Repeat count/Repeat to property. If they can be controlled by the event sheet, it would solve a lot of problems. But I don't think it's possible?

    Edit: I eventually found a workaround that gets almost the same effect. But thanks, I'll try that when I get back to working on them.

    The thing is I tried rex's Duration and Timer plugins, which theoretically should work, but still caused this weird error where my Deer started headbanging erratically and the speed of the animations started going out of whack. As in, they were exceeding the speed I placed in their animation properties.

    I have no idea if it was because of some severe event conflict, or I found some kind of bug. It looked like it had something to do with using the 'Is animation playing' event with a looping animation and the action is "Wait X seconds"

  • Here is an example that uses technique a little bit like the solution I mentioned before:

    Animation stuff

  • You can simple modify the "repeat count" on the event sheet or configure it when inside the image editor, it will loop the number of times your configured inside the repeat count.

    also, don't forget to configure the event to "trigger once while true"...

  • I can't find a way to manipulate the 'repeat count' of an image in the event sheet, except as just repeating one animation loop. Unless I can set "random(x,y)" in the image editor?

    However, thank you for the "Trigger once while/when true" special condition! That was exactly what I was looking for! Since the looping animations I were using were 'always true' which was the problem! I needed this system condition to tell it to count only the moment the animation starts!

    So yeah, all working as intended now!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)