About Store Forum Documentation Contact



Post Reply 
How to restart not looping animation
Author Message
kerryball Offline
Member

Post: #1
How to restart not looping animation
Hello everybody,

I have a linear animation which doesn't loop.
How can I restart this again and again after it has finished? To use loop is no option here!
07-10-2024 11:34 AM
Find all posts by this user Quote this message in a reply
tipforeveryone Offline
Bronze Supporter

Post: #2
RE: How to restart not looping animation
There is a "Loop" check box in your animation viewer wink
07-10-2024 02:30 PM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #3
RE: How to restart not looping animation
Not sure exactly what you are looking to do here, but if it's simply rerun an otherwise non-looped animation, as and when you wish to, then I suggest looking at Motion.h

I populate a motion structure and update it each game loop and call animate using the motion. The update functions return false when the animation has finished playing. The animation "Loop" check box setting is ignored when controlling the animation this way.
(This post was last modified: 07-11-2024 03:27 PM by Pixel Perfect.)
07-11-2024 03:06 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #4
RE: How to restart not looping animation
You can use the 'Motion' class.

you can use the Tutorial Game Basics 12- Animations as an example.

another example would be

Motion motion;

motion.time=0; which will play the animation again unless you use .clear() and have to reload the animation.

You can also extend it if you want to add more custom variables to it
class CMotion : Motion
{
CMotion(){repeats=0}
int repeats;
};

and do something with that, just putting an example from some old code I have lying around, excuse the syntax as this code is in Angelscript

Code:
if(animation.is())
{
    animation.Update(3, 3, 1); // update attack animation motion
    if(@target !is null)
    {
        SIItemCtrl  @wep=GetWeapon(Stat("SelectedWeaponSlot").IT());
        if(@wep !is null)
        {
            if (animation.eventBetween("hit-from","hit-to") && animation.repeat>0)
            {
                animation.repeat--;
                if(animation.repeat>1)animation.time=0;
                CAny @usemode=wep.UseMode();
            AtkDmg+=wep.UseFuncInt(this,target,wep,usemode.calculation);
            }
            if (animation.repeat==0)
            {        
                if(AtkDmg>0)target.ReceiveDamage(this,AtkDmg);
                AtkDmg=0;    
            }
        }
    }
}
(This post was last modified: 07-12-2024 05:04 AM by Zervox.)
07-12-2024 05:04 AM
Find all posts by this user Quote this message in a reply
Post Reply