Reset animation?

How can I cause an animation to start over from frame 1 after an event?

Comments

  • Cutscene EntertainmentCutscene Entertainment Member, PRO Posts: 138
    I'm pretty sure I can help you if you explain a little further. What exactly are you trying to do?
  • ChakkuChakku Member Posts: 1,513
    @redleaf

    Check the loop checkbox!

    And if you want it to loop only after a certain event, then make a rule When certainevent is true, change attribute animation to true

    If animation is true, animate

    Hope this helps
    Chakku :)
  • redleafredleaf Member Posts: 10
    @Chakku What I mean is that I want the animation to reset when an event happens before the animation reaches the last frame. Is there some way to access the exact frame the animation is currently on, like self.animation.frame = 1 etc?

    I would want the function to work like this:
    When attribute "foo" = "bar"
    set self.animation.frame to 1
    Then continue the animation from there.
  • ChakkuChakku Member Posts: 1,513
    edited January 2013
    @redleaf

    NO, that's not currently possible with creator. However, you can play around with the animations frames per second and keep track of time in the background, so you can check what frame the animation is on after a certain number of seconds, once that event happens. You must create many actors each with starting on a different frame of the animation. And then you can spawn the particular animation actor on top of the other one. This will give you the same effect :)

    Note that you don't have to do it exactly the way I specified above.

    Hope this helps
    Chakku
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Use a change image behavior to change the image to the original image when the event happens. Just be sure the animation stops when the event happens.
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    If you destroy the actor and spawn a new one at the same time the animation will play from frame one.
  • ChakkuChakku Member Posts: 1,513
    If you destroy the actor and spawn a new one at the same time the animation will play from frame one.
    Whoops :D...meant to say that he also needed many actors each with a different starting frame, and he had to create a rule that specified which one should be spawned depending on the current frame.

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

    Whoops :D...meant to say that he also needed many actors each with a different starting frame, and he had to create a rule that specified which one should be spawned depending on the current frame.
    All he has said is that he would like "the animation to reset when an event happens before the animation reaches the last frame" - he's not mentioned anything about needing actors with different starting frames ?

    You can do this by destroying the current actor when this event / trigger happens and spawn a new one in its place, the new actor will start its animation from frame one.
  • ChakkuChakku Member Posts: 1,513


    All he has is that he would like "the animation to reset when an event happens before the animation reaches the last frame"
    @Socks

    He also wanted to know how to know what frame the animation is on; that's why I suggested he create an integer attribute that increases by one every x seconds (x= his animation's FPS).

    Chakku :)
  • SocksSocks London, UK.Member Posts: 12,822
    . . . you can play around with the animations frames per second and keep track of time in the background, so you can check what frame the animation is on after a certain number of seconds . . .
    This won't work as the animation frame rates are unstable and bear no relation to the claimed frame rates (for example 29, 28, 27, 26, 25, 24, 23, 22 and 21 frames per second in the animation behaviour all run at 20.1 fps).



  • ChakkuChakku Member Posts: 1,513
    @Socks

    Well say it's set at one frame per second. Then every second change integer attribute scene.animationframe to scene.animationframe+1. Then 16 seconds later he want to know what frame it's on, it'll be frame 16, as it's going at 16 FPS?

    This is, of course, in theory, as I haven't tested it yet.

    Chakku :)
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    He also wanted to know how to know what frame the animation is on;
    In the context of his question I suspect that when he said . . .

    Is there some way to access the exact frame the animation is currently on, like self.animation.frame = 1 etc?

    . . . he was asking how to access (as in 'goto') a particular frame, specifically frame 1.

    (That was my interrelation at least).
    that's why I suggested he create an integer attribute that increases by one every x seconds (x= his animation's FPS).
    I'm not quite sure how this would help (maybe I don't quite understand what you are getting at) ?

    For example if his animation was running at 24 fps he would create an attribute that increases by 1 every 24 seconds ? What would he do with this attribute, what use would it be to him ?

    Confused.
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    Well say it's set at one frame per second. Then every second change integer attribute scene.animationframe to scene.animationframe+1. Then 16 seconds later he want to know what frame it's on, it'll be frame 16, as it's going at 16 FPS?
    Let's imagine this idea works (I suspect it doesn't) - how would he make use of it ?
  • redleafredleaf Member Posts: 10
    If you destroy the actor and spawn a new one at the same time the animation will play from frame one.
    This solved my problem perfectly. Thanks.

  • DanDaMan123DanDaMan123 Member Posts: 216
    I think a more clean way would be to have a boolean attribute like animatetrigger or something and then have a rule that said if animatetrigger=true then do the animation, and when you wanted to restart the animation you would turn animatetrigger off and then back on. Also, why would you want to reset the animation in the middle?
Sign In or Register to comment.