Stop animation in specific frame

  • #1, by TinTinThursday, 28. January 2016, 09:21 8 years ago
    Hi
    Sorry maybe it's a easy question but I can't find answer in forum .VS manual is not great too.
    I want more than 1 frame in standing animations.How can I stop it in last frame?

    Forum Fan

    196 Posts


  • #2, by Simon_ASAThursday, 28. January 2016, 11:58 8 years ago
    It's in the wiki!

    setAnimFrames("anim_name", first_key, last_key)
    


    Example:

    You create an animation named "my_anim" with 15 frames.
    Then use:
    setAnimFrames("my_anim", 5, 8)
    

    It will play animation "my anim" from frame 5 to frame 8.


    If you want to freeze on last frame, you can do:
    setAnimFrames("my_anim", 15, 15)
    


    Good luck!

    Great Poster

    321 Posts

  • #3, by afrlmeThursday, 28. January 2016, 12:36 8 years ago
    He also needs to include the actual setAnimFrame function inside of a definition script, can't forgot about that otherwise it won't do anything. It's a workflow I created & thus is not an internal function.

    Add this inside of a definition script inside of the script section of the editor...
    function setFrames(anim, a, b)
     if b == nil then b = a end -- fallback in case only a value was entered
     -- + --
     ActiveAnimations[anim].AnimationFirstFrame = a
     ActiveAnimations[anim].AnimationLastFrame = b
    end
    

    Now to use this you would create an execute a script action part (wherever you need it - in an action block or inside of a specific frame of an animation).
    setFrames("test", 3, 8) -- play / loop animation "test" between frame 3 to frame 8
    

    or...
    setFrames("test", 3) -- force animation "test" to play / loop frame 3 only
    

    Imperator

    7278 Posts

  • #4, by TinTinThursday, 28. January 2016, 16:58 8 years ago
    Sorry I'm beginner and couldn't still success.
    I make new script in script editor and put this code there
    setFrames(anim, a, b)
     if b == nil then b = a end -- fallback in case only a value was entered
     -- + --
     ActiveAnimations[anim].AnimationFirstFrame = a
     ActiveAnimations[anim].AnimationLastFrame = b
    end
    


    And put this code in frame 1 of standing animations (I have two frames, 0 and 1)
    setFrames("right2", 1)
    

    right2 is my name of right direction in standing animation

    I haven't stop animation. where is my wrong?


    Forum Fan

    196 Posts

  • #5, by Simon_ASAThursday, 28. January 2016, 18:37 8 years ago
    Indeed I had forgotten the main definition script grin
    Anyway...

    TinTin:
    I make new script in script editor and put this code there
    Good! (make sure it is a definition script, not execution script)

    And put this code in frame 1 of standing animations
    I think this is why it doesn't work: don't put this code inside the animation, and call it from somewhere else.
    For example:
    - on left click, execute script (copy/paste the code).
    (There is an Action "Execute A Script" where you can write your own scripts)

    Great Poster

    321 Posts

  • #6, by afrlmeThursday, 28. January 2016, 20:17 8 years ago
    Yes, you can put it in your animation.

    The problem is that the editor says frame 0 but you can ignore that because the first frame index value is always 1, so the last frame of your 2 frame animation would be 2. wink
    setFrames("right2", 1)
    

    P.S: you actually want to add the execute a script action part containing the function & parameters into the frame that you want to stop it on. So add it to the final frame.

    Imperator

    7278 Posts

  • #7, by TinTinFriday, 29. January 2016, 08:01 8 years ago
    Sorry but it doesn't work yet.
    @Simon
    I paste it another location and not happened
    @AFRLme
    I paste it in last frame in standing. And not work.

    Forum Fan

    196 Posts

  • #8, by afrlmeFriday, 29. January 2016, 12:11 8 years ago
    Could you post some screenshots of exactly what you did please?

    Imperator

    7278 Posts

  • #9, by TinTinFriday, 29. January 2016, 13:50 8 years ago
    I make same method that you said.
    1.I made a script0 in script editor and pasted :

    setFrames(anim, a, b)
    if b == nil then b = a end -- fallback in case only a value was entered
    -- + --
    ActiveAnimations[anim].AnimationFirstFrame = a
    ActiveAnimations[anim].AnimationLastFrame = b
    end

    2.I pasted this code in frame 2 ( frame 1 in editor and it's last frame ). right2 is for standing animations :

    setFrames("right2", 2)

    It doesn't work even with 1 number too.

    I have this log :

    Implicit cast from 'int' to 'float'

    Script local label
    If use Tabletoolbar then label = "#Scripts" else label = nil end
    Objectlist ("Visobjects",took 111 ms

    Forum Fan

    196 Posts

  • #10, by afrlmeFriday, 29. January 2016, 14:03 8 years ago
    Do all your characters use the same animation names? If you have multiple characters on screen at the same time & they all have the same animation names, then the engine may be struggling to determine which ActiveAnimation to access.

    Would you mind sending me your ved & resource files? afrlme (at) outlook (dot) com.

    Imperator

    7278 Posts

  • #11, by TinTinFriday, 29. January 2016, 16:32 8 years ago
    I sent it.
    Sorry but my project was heavy so I made another project as default and paste your codes.please check your mail

    Thanks so much

    Forum Fan

    196 Posts