Jump to content
Sign in to follow this  
enad

How to make an Animation loop?

Recommended Posts

Hey guys, I'm using a few animations in a mission of mine, but they just do it for a few seconds and then go back to normal.

For example here is one:

this playmove "ActsPercMstpSnonWnonDnon_talking02";

So is there a 'universal' code I could put into the init box of the waypoints along with the animation code that would make it continuously go on!?

I really hope this is possible!

Thanks!

Share this post


Link to post
Share on other sites

animLoop.sqf

_unit = _this select 0;
_anim = _this select 1;

while{alive _unit}do{
_unit playMove _anim;
waitUntil{animationState _unit != _anim};
};

Call with:

0 = [this,"ActsPercMstpSnonWnonDnon_talking02"] execVM "animLoop.sqf";

Share this post


Link to post
Share on other sites

So where do I put that code? In the way point init after the animation code? Or what?

And what do you mean "Call with:" Do you mean stop it?

Share this post


Link to post
Share on other sites

Look up Scripts/Scripting

So where do I put that code?

In a file, called 'animLoop.sqf', and place it in your mission folder.

And what do you mean "Call with:"

That's the code you use to execute it (ie start the animation).

OR

You could do it in the editor. Pick an object (anything with an init field) and put this in the init field:

animLoop = {_unit = _this select 0; _anim = _this select 1; while{alive _unit}do{_unit playMove _anim; waitUntil{animationState _unit != _anim}}}

And then, in the waypoint/init of your unit playing the animation:

0 = [this,"ActsPercMstpSnonWnonDnon_talking02"] spawn animLoop

Share this post


Link to post
Share on other sites

AWESOME! That works for the most part!

I'm just having trouble getting this to loop.

this playmove "ActsPercMstpSlowWrflDnon_talking_C3BeginBriefing";

It doesnt want to loop.

I modified the code you gave me to this

0 = [this,"ActsPercMstpSnonWnonDnon_talking_C3BeginBriefing"] spawn animLoop

That didnt work, so I tried this.

0 = [this,"ActsPercMstpSnonWnonDnon_talkingC3BeginBriefing"] spawn animLoop

Anything?:confused:

ALSO...Is there a place where I can find all the animations listed? I know theres an ingame animation viewer, but I mean a webpage or something that I can look at. If not, I'll just DL the Ingame Animation viewer.

Share this post


Link to post
Share on other sites

It's most likely related to the specific anim you're trying to loop. Some anims transition smoothly when you use playMove, some don't. You could try replacing the playMove with a switchMove, but be advised it might not be as smooth as a transition.

---------- Post added at 03:57 PM ---------- Previous post was at 03:56 PM ----------

ALSO...Is there a place where I can find all the animations listed? I know theres an ingame animation viewer, but I mean a webpage or something that I can look at. If not, I'll just DL the Ingame Animation viewer.

I'm pretty sure there's one on the Wiki.

Share this post


Link to post
Share on other sites

Unless I'm not mistaken, you can just play the desired animation and prevent the unit from changing that animation with disableAI "ANIM", thus creating an infinite loop. Though it may be that this only works for a subset of the available animations.. (probably with those that have loop-points or something)

Give it a try.

Oh. And if you do such things, you probably want to give the unit some kind of eventhandler or run a script that checks the damage of this unit. The unit needs to be allowed to change its animation to die (something like: if (!(alive _unit)) then allow to switch animation, switchMove "" and fall dead...).

Edited by ruebe

Share this post


Link to post
Share on other sites
This isn't working at all.

Works fine, if used from a units init but if you call from a trigger you need to change "this" to the units name.

Also do you get any errors.

Share this post


Link to post
Share on other sites
Works fine, if used from a units init but if you call from a trigger you need to change "this" to the units name.

Also do you get any errors.

Nope it just did nothing in a units init.

While we're on the subject, I have setup an animation loop of two men that have their hands tied.

When you enter the trigger area it is supposed to release them and make them follow.

Right now when you enter the trigger area they join your group but cannot walk because of the animation holding them down

How do I stop them from continuing the animation loop I have setup on them?

Edited by Toasticuss

Share this post


Link to post
Share on other sites

Deleted as it's to confusing

Edited by F2k Sel

Share this post


Link to post
Share on other sites
Assuming your using the script you posted to I changed the while {true} and add a variable stopthem=1;

_unit = _this select 0;
_animation = _this select 1;
_noWeapons = _this select 2;
stopthem=1;
_unit setVariable ["BIS_noCoreConversations", true];
if (_noWeapons) then {removeAllWeapons _unit};

while {stopthem==1} do {
_unit switchMove _animation;
waitUntil {!(animationState _unit == _animation)};
};

now when you want it to end just stopthem to 0 in a trigger

stopthem=0

Hmm I put "stopthem=0;" in the trigger but It didnt help.

Nice work though.

Share this post


Link to post
Share on other sites

Deleted as it's to confusing

Edited by F2k Sel

Share this post


Link to post
Share on other sites
Did you replace the script with the new one I posted.

D'OH, nice thinking.

Edit: But it didnt work :cry:

Edited by Toasticuss

Share this post


Link to post
Share on other sites

Deleted as it's to confusing

Edited by F2k Sel

Share this post


Link to post
Share on other sites
I have no idea what your doing unless the script isn't being called by the trigger as it works fine for me.

Anyway I have maybe a better way as that will stop all animations at once.

Go back the script that was working then change the first part of the line that calls the script instead of nil=[ rest of code... change it to actor1=[ rest of code ....

now to end the script you would put terminate actor1 in ta trigger or waypoint on act.

For every unit though you would need a different code actor2=[ restof code.. ect, and a terminate actor2 to match

That way you can stop just the units you want and not all of them at once

I'm not sure about the negatives of using terminate, others may have thoughts on this.

This is what the trigger looks like

[pilot1,pilot2] join group1; hint "Pilots secured well done. A chopper is enroute to the extraction point.";obj1 setTaskState "SUCCEEDED"; player setCurrentTask obj2; obj1 = true; publicVariable "obj1";unit1 setBehaviour "aware";unit2 setBehaviour "aware";unit3 setBehaviour "aware";unit4 setBehaviour "aware";unit5 setBehaviour "aware";stopthem=0 execVM "scripts\animationLoop.sqf";

Am I calling it wrong?

If you were to do it your way what would the code be?

pilot1 = [this,"ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes",true] execVM "scripts\animationLoop.sqf";
Edited by Toasticuss

Share this post


Link to post
Share on other sites

Deleted as it's to confusing

Edited by F2k Sel

Share this post


Link to post
Share on other sites
[pilot1,pilot2] join group1; hint "Pilots secured well done. A chopper is enroute to the extraction point.";obj1 setTaskState "SUCCEEDED"; player setCurrentTask obj2; obj1 = true; publicVariable "obj1";unit1 setBehaviour "aware";unit2 setBehaviour "aware";unit3 setBehaviour "aware";unit4 setBehaviour "aware";unit5 setBehaviour "aware";stopthem=0 

it's just stopthem=0

I had it just like that before I added the execute command, how does the trigger know where that command links to? Does the game just scan through all available files until it finds that string?

Trying your other way.

---------- Post added at 08:53 AM ---------- Previous post was at 08:46 AM ----------

Other way didnt work either.

Heres what I have right now

Pilot 1s init

disableAIMove = 1; this setBehaviour "careless"; this allowFleeing 0; doStop this;this allowDamage false;nul=[this,7+2] execVM "setbpos.sqf";pilot2 = [this,"ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes",true] execVM "scripts\animationLoop.sqf";

Pilot 2's is the same except for the number after the word pilot

Trigger -

[pilot1,pilot2] join group1; hint "Pilots secured well done. A chopper is enroute to the extraction point.";obj1 setTaskState "SUCCEEDED"; player setCurrentTask obj2; obj1 = true; publicVariable "obj1";unit1 setBehaviour "aware";unit2 setBehaviour "aware";unit3 setBehaviour "aware";unit4 setBehaviour "aware";unit5 setBehaviour "aware";terminate pilot1; terminate pilot2

The code is back to its original state as well.

Doing this method also makes them also no longer join my group.

Edited by Toasticuss

Share this post


Link to post
Share on other sites
see if this will work I've used OA map and units.

http://www.sendspace.com/file/72n584

I've deleted all my previous posts as it was way yo confusing to keep track of.

Alright ill let you know.

Okay, its kinda working.

When I load that mission he isnt doing any animation just standing there but he does move in 5 seconds.

http://www.mediafire.com/?2m0zm3ywyzi

Here look at this revised one. Its still broken.

You had a space in the animation and he wasnt doing anything.

Edited by Toasticuss

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×