[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: 25
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: 1178
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: 25
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: 25
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: 1178
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

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

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

Post by pg_interactive » Wed Dec 26, 2018 6:15 pm

Hello, im adding to this post as a response to this thread, since im about to test your garbage collector fix from yesterday (from this thread), but there is still this issue with the "resolving correct Tuple namespace".

Paste what MS Visual Studio says:

Code: Select all

'Tuple<,>' is an ambiguous reference between 'MeshBoneUtil.Tuple<T1, T2>' and 'System.Tuple<T1, T2>'
AFAIK this should only happen in newer version of C# (which i am using in the project, might not happen to you, if you're using older C# version, or older Unity Engine version). Can i suggest you use 'MeshBoneUtil.Tuple' instead of 'Tuple' in your code to resolve the conflict? This will help me and others like me - to not have to refacture the plugin code every time we do a plugin update.

Example old code:
CreatureGameController.cs, 184

Code: Select all

var basis_pair =
                new Tuple<XnaGeometry.Vector2, XnaGeometry.Vector2>(basis_start, basis_end);
Example same code after refactoring:

Code: Select all

var basis_pair =
                new MeshBoneUtil.Tuple<XnaGeometry.Vector2, XnaGeometry.Vector2>(basis_start, basis_end);
EDIT: You're correct, your Tuples are in MeshBoneUtil namespace, and you did import the namespace in the class, but at the same time, you imported the System namespace in the same class, so i guess that creates the conflict for VS/Unity.

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

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

Post by chong » Wed Dec 26, 2018 9:39 pm

Hello,

Actually I fixed it that way in the new code because the old code had issues in Unity 2018. The new code compiles and runs with the latest Unity 2018 ( downloaded from their site )

Thanks

pg_interactive
Posts: 25
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 Dec 27, 2018 3:48 am

Correct, U2018 is using C# 7, which implements System.Tuple, but i don't understand what you mean (by "new code"), did you update the Creature Unity runtimes with the MeshBoneUtil namespace prefix, or should i change something on my side (because the repo i downloaded yesterday, when i was testing the Garbage Collection still had the conflict).

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

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

Post by chong » Thu Dec 27, 2018 9:53 am

I updated it to use MeshBoneUtil namespace prefix in order to get it to build properly in Unity 2018 for me.

Post Reply