Jump to content
Sign in to follow this  
blackpixxel

SwitchAnimation does not work

Recommended Posts

Hi,

I have a reload animation that is a loop of a single animation.

while {...} do
{
   _unit switchAction "ReloadAction1Stand";
   sleep 0.8;
}

The problem is that the game does not play the animation. But when I use "playAction" or "playActionNow" it will work. But then I always have a short transmission between the animations. When the player is running and reloading the weapon will go back into running position during this transmission.

Can anyone help me?

Thank you for your time!

BlackPixxel

Share this post


Link to post
Share on other sites

Most reload animations are configured as Gestures, meaning they are layered over a base animation like standing still or running, and only involve the weapon, arms and head. That setup makes it possible to reload while running for example, it does not interrupt the underlying animation. Is the animation you're trying to trigger set up as gesture, and if so, have you tried playGesture. Apparently it doesn't work, but who knows, maybe they implemented/fixed it..

Share this post


Link to post
Share on other sites

Yep, it is a gesture, and it works with playAction. But this command does not do anything.

My problem is that in the time between two gestures the upper body switches back to the normal walking animation. This interruption for a splittsecond is very anoying and makes the whole thing look very bad.

I would need something to keep the upper body from going back to the normal animation between two gestures. I thought that switchaction would do that by instantly switching to the new action, but it does not work..

Share this post


Link to post
Share on other sites

Maybe the animation is a bit shorter than 0.8 seconds (your sleep delay), so when it finishes, the character reverts back to the base animation for a split second. Maybe it isn't even possible to play those animations in a perfectly seamless loop, using scripting commands like play/switch/Move/Action/Gesture.

It might be a wild goose chase, but in your place I might try and set up an event handler for AnimChanged, AnimDone and AnimStateChanged, see if either picks up on the reload animation finishing, and use that event to time the next call for the reload action/animation.

Or try making an addon out of it, if it's practical for you or suits your needs. That way you might have better control over it, than what scripting commands afford you at this time.

Share this post


Link to post
Share on other sites

In the animation config is an entry called "looped=0;" .

The wiki says that the animation should repeat itself if set to 1. I now had the plan to just loop it and then interrupt it when I dont need it anymore. This could result in more smoothnes. But it also does not work. The animation is only played once.

I dont really want to use more eventhandlers because I am afraid that it wont work really well in multiplayer.

Share this post


Link to post
Share on other sites

Setting looped=1 should work, just make sure to add the animation state itself into it's own connectTo[]= array, otherwise it cannot be followed by itself, loop that is. Look at the way looping animations are configured.

Share this post


Link to post
Share on other sites

I know added the line in the config:

class ReloadAction1Stand: Default

{

file = "\tb_arifle_hkump45\anim\Handanim_hkump45_reload1.rtm";

ConnectTo[] = {"ReloadAction1Stand", 0.95};

looped=1;

speed=1.2;

mask="handsWeapon";

headBobStrength=0.200000;

headBobMode=2;

rightHandIKBeg=0;

rightHandIKEnd=0;

leftHandIKCurve[]={0,0,0.50000,0,1,0};

// leftHandIKCurve[]={0,1,0.050000,0,0.950000,0,1,1};

// leftHandIKCurve[] = {};

// enableOptics=1;

// aimPrecision = 5;

};

But it just plays the animation one single time. What am I doing wrong?

Thank you for your help!

Share this post


Link to post
Share on other sites

I can't find a fault in your config, but place yourself a character in editor, paste this into it's init field this playAction "GestureAgonyCargo"; then hit Preview.

As you can see, it is possible to have seamlessly looping gestures. Copy the way it's set up in the animation config, and you should be set.

Share this post


Link to post
Share on other sites

The problem is already solved. I made a copy of the first animation. Then I set both to loop and connected them to each other. This creates the expected animation loop.

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  

×