[Unity] Stop animation loop and small visual glitch between AnimationReachedEnd->SetActiveAnimation

Discuss issues pertaining to the various game/web runtimes of Creature here.
Post Reply
pg_interactive
Posts: 16
Joined: Thu Feb 22, 2018 2:42 pm

[Unity] Stop animation loop and small visual glitch between AnimationReachedEnd->SetActiveAnimation

Post by pg_interactive » Thu Jul 26, 2018 7:29 am

Hi,

I have 2 questions.

1) I'm almost positive, that this was not an issue before. In unity, animation set to not loop in inspector's creature renderer are looping. Same if they are set like this:

Code: Select all

creatureRenderer.should_loop = false;
Is this something introduced lately, or is it something i might have setup wrong?

2) There is a visual glitch visibly for exactly 1 frame when switching animations programmatically, specifically:
When say animation1 finished playing, and

Code: Select all

override public void AnimationReachedEnd(string anim_name)
triggers, and within that function we decide to play an animation2, using either:

Code: Select all

creatureRenderer.BlendToAnimation(animation2_name);
or

Code: Select all

creatureRenderer.SetActiveAnimation(animation2_name);
then right after one of the above options executes, the next frame displays first frame of animation1, and frames after that correctly display animation2. Might this be related to the looping "bug" in point 1)? Considering the bug only occurs during 1 frame in a - lets say - 60fps animation, its not so bad, but noticeable, the more the first frame of animation1 differs from the first frame of animation2.

Thank You.

chong
Posts: 835
Joined: Thu Feb 19, 2015 2:21 am

Re: [Unity] Stop animation loop and small visual glitch between AnimationReachedEnd->SetActiveAnimation

Post by chong » Thu Jul 26, 2018 7:43 am

Hello,

The glitch might be related to the looping bug, yes.

I just checked in a fix for the looping bug, please sync up with the latest GitHub changes:
https://github.com/kestrelm/Creature_Unity

Thanks

pg_interactive
Posts: 16
Joined: Thu Feb 22, 2018 2:42 pm

Re: [Unity] Stop animation loop and small visual glitch between AnimationReachedEnd->SetActiveAnimation

Post by pg_interactive » Thu Jul 26, 2018 7:48 am

Thank you @chong, You are extremely quick!

pg_interactive
Posts: 16
Joined: Thu Feb 22, 2018 2:42 pm

Re: [Unity] Stop animation loop and small visual glitch between AnimationReachedEnd->SetActiveAnimation

Post by pg_interactive » Thu Jul 26, 2018 8:26 am

While i'm here, ill also give you a heads-up on .NET4+ in Unity that contains definition for System.Tuple, which will conflict with your usage of your custom Tuple. So as a quickfix, you can just prefix your Tuple usage with MeshBoneUtil (since it already exists in that namespace).. will help us .NET4+ users.

EDIT: regarding the glitch from first post:
No more glitch using (no blending):

Code: Select all

creatureRenderer.SetActiveAnimation(animationName);
Glitch still occurs when blending from animation to animation, eg:

Code: Select all

creatureRenderer.BlendToAnimation(animationName);

chong
Posts: 835
Joined: Thu Feb 19, 2015 2:21 am

Re: [Unity] Stop animation loop and small visual glitch between AnimationReachedEnd->SetActiveAnimation

Post by chong » Thu Jul 26, 2018 4:07 pm

Hello,

The Tuple definition is in the namespace of MeshBoneUtil so there shouldn't be a conflict I think.
Regarding the glitch, I just tested a simple run and idle fox animation using a MecAnim setting but it seems to be fine.

I am using this module:
https://github.com/kestrelm/Creature_Un ... ehavior.cs

As you can see, it too also calls BlendToAnimation() programmatically and I set it up so that I can consistently test the behaviour. I checked the code for BlendToAnimation, it does not seem to set the original animation to the first frame either. Perhaps more investigation is needed?

Update: I just checked in a change, you can sync up. I am not sure if this fixes your problem, but now I also forcefully update the original blending animation time with your current time. Again as I said, I could not repo the issue in the setup I described above. If you look at the active_blend_run_times Dictionary you should be able to understand what the relationship is between your animation clip and your runtime during blending.

Thanks

Post Reply