Jump to content
gc8

Looping one animation

Recommended Posts

Hi

I'm trying to make the player run one animation as long as I want but haven't figured how to do this... Here's my code:

 

[] spawn 
{
sleep 1.2; 

lastPlrAnim = animationState player; 

while { true } do
{
 player playMoveNow "Acts_carFixingWheel"; 

 sleep 1;
 waituntil { animationState player != "Acts_carFixingWheel" };

 hint format['continue %1', time];  

 player playMoveNow lastPlrAnim;  // Without this everything get's messed up

 sleep 3;
};

};


It loops but I have to reset the animation using "playMoveNow lastPlrAnim;". It would be best if I could just run the fixing animation again

 

anyone know how to do this properly?

 

thx!

 

 

Share this post


Link to post
Share on other sites

I use the AnimDone eventHandler and it works pretty good for me.

  • Thanks 1

Share this post


Link to post
Share on other sites
15 minutes ago, phronk said:

I use the AnimDone eventHandler and it works pretty good for me.

 

do you use playMoveNow? Because I can't get it to work any better with the EH. 

 

tried this code but the anims got messed up:

 

player addEventHandler ["AnimDone", {
params ["_unit", "_anim"];

 hint format['anim done %1', time];  
[] spawn 
{
sleep 3; 
 player playMoveNow "Acts_carFixingWheel"; 
};

}];



[] spawn 
{
sleep 1.2; 

 player playMoveNow "Acts_carFixingWheel"; 

};

 

Share this post


Link to post
Share on other sites

I would recommend switchMove, however, any player movement will break the animation. Might need to disableUserInput for the duration of the animation or whatever to prevent that.

Share this post


Link to post
Share on other sites
6 hours ago, phronk said:

I would recommend switchMove, however, any player movement will break the animation. Might need to disableUserInput for the duration of the animation or whatever to prevent that.

 

Nice, I got it working using first playmoveNow and then switchmove in the EH 

In switchmove the player can move to break the anim but not in playmovenow. so it's quite not perfect yet but this is my code so far:

 

player addEventHandler ["AnimDone", {
params ["_unit", "_anim"];

if(_anim == "Acts_carFixingWheel") then
{

 hint format['anim done %1', time];  
 player switchmove "Acts_carFixingWheel"; 

};

}];



[] spawn 
{
sleep 1.2; 

 player playMoveNow "Acts_carFixingWheel"; 

};

 

Share this post


Link to post
Share on other sites

I was able to get the animation to continue with playmoveNow using this code in the EH:

 

 player switchmove "Acts_carFixingWheel"; 
 player playMoveNow "Acts_carFixingWheel"; 

 

But I don't know if that's proper usage of the animation system

 

Share this post


Link to post
Share on other sites

If it works it works! Good job.

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

×