Unity animation transition glitches back to last animation - unity3d

So, I have my animation and it goes to an empty state.
The thought behind this is that it goes to it's default no animation state.
However, before it does that, it glitches back in to the old animation.
I tested it, it only happens whenever I go from an animation to an empty state.
It always glitches for the same amount of time for each transition, however it is different for each transition.
I have never seen something like this before, does anyone of you know the problem?
The animation
The clear state
The transition

What do you mean by glitching? I am going to take a guess and say you do not want an exit timer, so uncheck this box.
An exit timer is just used to transition between two states and will take the amount of time to wait to transition. In your transition block, it also shows you stacking your two animations which might be why everything looks weird for a short time. Instead of an exit timer, you might want to use parameters to change your states or directly set them in code.
The other possible issue is the checkbox Write Defaults.
From the Unity Docs, the description of Write Defaults is
Whether or not the AnimatorStates writes back the default values for
properties that are not animated by its Motion.
Unexpected behavior with animators can be caused by Write Defaults if you are not familiar with how they work or what they do. Again, it is hard to say what exactly is wrong with the description of your issue. Try unchecking each of these boxes individually and seeing if either one fixes your issue. If that does not work, try both and if that does not work, let me know what your issue is in more detail. Possibly attach a gif or video showing what is breaking as the written description is not helping too much.

Related

How can I swap out a unity animation for another while keeping the same duration into the animation?

I've seen this question asked here but it was never answered, and mines a bit different.
As an example: lets say I'm making a character that's constantly on a looping animation, and I have a button that you can hold down to make the character wear sunglasses, the sunglasses are kept on a separate animation of the same framerate and frame count. How can I use the button to switch them but start the new animation on the same frame as the last?
Edit: I've found a function for animators called PlayInFixedTime() this is the documentation for it, I don't know what it does but it mentions a "time offset" so it could be what I'm looking for, but I have no clue.
In my opinion you can solve this in 2 ways:
Animation Events: via script you are able to select the end of an animation even if it is looping
Wrap mode: there is an example here (https://answers.unity.com/questions/37080/stopping-an-animation-from-looping-at-the-end.html) but basically you are able to play an animation in Queue after the end of the previous. You can do it with a simple function so you are able to reuse it many times

Avatar removed from Pivot point

I was animating an avatar, and was trying various things out, and all of a sudden she was transformed from her pivot point. She also lost the T-pose. I couldn't figure out how to get her back to the original state, removing the animation didn't help. I am going to deleting that avatar and start over, but first I want to learn from this.
I am really looking for a few things here:
how could that happen? It looks like somehow the state at some point of the animation became the new "ground" state or something.
is there anyway I could inspect this state, edit it, or failing that, reset it?
is there something I should read somewhere to understand this better? I found nothing
Screen shot of displaced avatar:
The top level inspector in the heirarchy:
Here is one with the animator controller:
Update:
The key was the suggestion by Fiffe that you need to make sure your flow gets to your exit state. In my case I was neglecting to do that.
There's few things that might be causing this. You probably wanna play around with animation clip settings - you can find them by selecting animation clip.
You can read more about it here https://docs.unity3d.com/Manual/class-AnimationClip.html
You probably want to turn off Apply Root Motion in your Animator too.
If that doesn't help you should check if you don't have any empty states (without animations) in your animator controller.

Is there any way to make an animation just using CGContext on iOS?

Well, I want to make a animation application on iOS. So, I make an application using UIViews... But, it's very complicated. There are so many UIViews so I want to make it simple. So, There's any way to make an animation just using CGContext just one UIView? If someone knows PLS help.
You could use a timer that repeatedly fires so you call setNeedsDisplay every 0.01 second or something, and calculate every rectangle, circle, line, whatever to the right places at every time instant. You may well suffer some issues this way, though, since drawRect won't get called instantly every time, meaning you'll need to check the actual time when drawRect fires. You might even need to take the time it takes to execute your code into account.
Or just move the UIViews around in stead, using animateWithDuration:. I recommend that. No matter how complex your hierarchy is, doing it all in a single view will always be more complex.

Synchronizing CAAnimations

I have a repeating animation that I need to synchronize with some other transient animations. The repeating animation is a scan line that moves across the screen for 4s. As it passes over images underneath, those images need to "blip."
The blipping images can come and go and move at the whim of the user. They are also not part of the same layer.
I can't figure out how to keep the scan line and the image animations in sync. I would consider adding them all to a CAAnimationGroup, but the "animations" property is a readonly NSArray, so it seems like I'd have to re-create the group every time one of the blipping animations is added, removed, or moves, which will be fairly often. I'm also guessing that creating a new group would mean the scan line animation would need to be restarted, causing it to be jerky.
According to this post:
=">CAAnimation that calls a method in periodic animation-progress intervals?
Core Animation is "time-based," but I'm not sure I fully understand what that means for a repeating animation and how reliable it is (I can't find this mentioned in any of the online documentation). Does that mean if I start the scan line repeating animation at time x, it will repeat at exact 4s intervals after it's been started? What about the app going to the background and returning or similar?
Thanks for your help!
Ryan
After fiddling with this for a bit, I found that I could synchronize my animations by making sure their beginTimes lined up. I started by setting the beginTime of the scan line animation:
scanAnimation.beginTime = CACurrentMediaTime();
From there I simply computed the offset within the 4s window (call it dt) and set the other animations' beginTimes to that:
blipAnimation.beginTime = scanAnimation.beginTime + dt;
This worked perfectly even if the beginTime was in the past; the animation engine actually extrapolated forward and animated the next blip dt seconds after the scan animation looped back.
The downside is that I've now absolutely bludgeoned the frame rate. I'm trying to find useful information about Core Animation performance, but so far to no avail. I've taken a pretty simple approach to laying out all of my images and animations so far and I'm prepared to rewrite a lot of code to optimize it, but I don't want to embark on a rewrite without some preparation. Any pointers to in-depth discussions about how Core Animation works would be really handy.

How can we get kCAOnOrderOut to work?

The Apple documentation claims that the Core Animation action key kCAOnOrderOut has one sole purpose: to animate a layer out of sight when it either becomes hidden or has -removeFromSuperlayer called on it. I'm only referring to the latter case in this question.
In practice, when -removeFromSuperlayer is called, the layer is removed immediately, and no animation is performed on it.
It's been hinted at that this is a difference between the Presentation and Model layers, but I'm not experienced enough in Core Animation to know what to make of this.
If anyone can explain how to force the animation to run before the layer is removed, when the animation is returned for the key kCAOnOrderOut, it would be appreciated by at least me and a few other people.
Thanks.
I have no idea how to implement it with the key kCAOnOrderOut, but I ran into a similar problem a while back. My fix was to set the animation with a specific duration and immediately send off a delayed timer that waited the same amount of time as the animation duration. After my timer fired I would remove the layer/view.