How to stop looping animation?

Discussions about Coding and Scripting
User avatar
Deepu
Adept
Posts: 262
Joined: Mon Nov 11, 2013 7:56 am
Personal rank: Average
Location: India

How to stop looping animation?

Post by Deepu » Sun Dec 12, 2021 6:40 am

Tried to stop looping animation in weapons while using firing and idle sequence, there is no such way to stop those animation? while weapon is dropped on the ground and getting from another player or bot?

Code: Select all

	LoopAnim('Shoot2',1.9);
	LoopAnim('Idle',0.2,0.9);

User avatar
sektor2111
Godlike
Posts: 5873
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: How to stop looping animation?

Post by sektor2111 » Sun Dec 12, 2021 11:08 am

"FinishAnim()" called somewhere after pickup... or switching to "select" if animation exists...

Must be tested...

User avatar
Deepu
Adept
Posts: 262
Joined: Mon Nov 11, 2013 7:56 am
Personal rank: Average
Location: India

Re: How to stop looping animation?

Post by Deepu » Sun Dec 12, 2021 3:03 pm

Put FinishAnim() in function dropfrom? let me try

User avatar
Feralidragon
Godlike
Posts: 5454
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: How to stop looping animation?

Post by Feralidragon » Sun Dec 12, 2021 3:11 pm

FinishAnim() is just a latent function (meaning it can only be used in state code) that waits for an animation to finish, it doesn't stop the animation itself.
It's like a sleep function, but rather than sleeping for X amount of time, it sleeps until the ongoing animation ends.

Looping animations never "finish", they just keep looping forever, so FinishAnim() won't have any effect in "waiting".
In the same way, AnimEnd(), which is similar to FinishAnim(), in the sense that it's called when an animation finishes, also never gets called for looping animations.

So, answering the actual question: you can only stop a looping animation by playing a normal animation.

This means that you need to call either PlayAnim(...) or TweenAnim(...) for the looping animation to stop, for example: a tween animation back to Idle, and to be fast you can give it a very short time (not sure if using zero works, but you may try it out).

User avatar
Deepu
Adept
Posts: 262
Joined: Mon Nov 11, 2013 7:56 am
Personal rank: Average
Location: India

Re: How to stop looping animation?

Post by Deepu » Sun Dec 12, 2021 4:15 pm

PlayAnim or TweenAnim is not correctly working like as LoopAnim

Code: Select all

simulated function PlayIdleAnim()
{
	if ( !LoopingAnim( 'Idle') )
		LoopAnim( 'Idle', 0.4);
}
simulated final function bool LoopingAnim( name AnimName)
{
	return IsAnimating() && bAnimLoop && (AnimSequence == AnimName);
}
What about this? still not working :noidea

User avatar
Feralidragon
Godlike
Posts: 5454
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: How to stop looping animation?

Post by Feralidragon » Sun Dec 12, 2021 4:24 pm

Not sure what you mean by that, especially given that you're not showing how you used the tween/play functions, but to clarify: I mentioned TweenAnim and PlayAnim to end the ongoing looping animation, and not to replace it entirely.

In other words, you start your looping animation as usual, then once you want to stop it is when you call a tween or play function.

User avatar
Deepu
Adept
Posts: 262
Joined: Mon Nov 11, 2013 7:56 am
Personal rank: Average
Location: India

Re: How to stop looping animation?

Post by Deepu » Sun Dec 12, 2021 5:55 pm

let me test with TweenAnim and PlayAnim.