Accuracy of animation editor inconsistant

Hi

I have a simple cube that I animate from -76,75,1000 to -66,75,1000 over one second.

I created this clip using the animation editor that is built into Unity 3.0 Beta 5, I set the start position tangents to Flat so its animation eases out.

Here are 5 separate results where the cube stops when its animation is complete.

-66.10669,75,1000
-66.07936,75,1000
-66.0831,75,1000
-66.10153,75,1000
-66.06033,75,1000

Why is it doing this, I need to it stop at the position I set exactly at the 2nd keyframe.

Thanks
Geoff

Why do you need to stop it at exactly that point? Is it for art reasons, or code reasons?

I don’t really care how accurate the real world coordinate position is on the 2nd keyframe (like what might be important in AutoCAD) but I do care that the animated object isn’t reaching the position set at the keyframe in Unity. That is something else.

My problem is that I have a zoomed in shot of an object moving into an exact location, like a jigsaw puzzle. An inaccuracy of 0.1 in the objects transform is about a 1 cm in screen space away from where it should be. I use animation events too so don’t want to do this via script.

Thanks
Geoff

This happened to me on a past project. Impression I got after asking was that it was just how the animation editor is and I shouldn’t try and use it that way. I was pretty disappointed since I had all kinds of plans to use the editor to drive animations that drive scripts that drive animations, etc, etc, etc. In my case, the breaking point was a completely inconsistent problem with easing through points, causing a distracting bouncy-followthrough when the camera should have come to a complete stop.

If this issue is the same as mine it has to do with how the Animation script functions.

When playing an animation it’ll sample what keyframe it should be at for each frame, however it doesn’t force the last frame.

So if you have a 1 second animation, and the last frame plays at 0.98 seconds, if the next frame takes 0.03 seconds it won’t sample the animation at the end and just end it. This leaves you with your animation finishing slightly incomplete. There are a few solutions:

  1. Set animations to Clamp Forever. Easy fix for when you can, not always an option though.

  2. Make sure to sample the last frame after the animation plays. This can be done with a Coroutine (wait for the animation to play, once it played fully set it to the end and sample it once, similar to the one I wrote up in your Wishlist post).

  3. Add a few extra frames to each animation so that it has a guaranteed chance of hitting that final key. This will make it harder to measure the length of you animations.

@Defmech
To stop the bounce, you need to set the animation curve to be Constant at the ends. Right click on the last Keyframe and set edit Right Side curve, and then choose Constant. That should fix it, as it’s trying to bezier curve animation points you don’t want beziered.

Thanks for the tips again! Will give these a try today.

Do what Ntero says :slight_smile:

He is right - it’s a problem/bug in our animation system, it doesn’t sample last keyframe in some cases. I hope to get to that bug sometime :slight_smile:

Paulius,

Should we end users report this “animation system doesn’t sample last keyframe” bug so it gets escalated? or doesn’t that matter if you know about it already?

No, there is no need to report it since we have it already. A bug being mentioned on the forum more times (or having more bug reports from different users) kind of let’s us know that the bug is more important.

Sorry for the late response on this. I tried every combination of curve and nothing fixed it. Even with every point set to constant, it would still follow through sometimes. I’d even manually enter 90 degrees for the last key, for example, but even that would immediately change to something like 90.lotsofnumbers as soon as I hit enter. Some animations would do this and some wouldn’t. Someone said that it was a side-effect of calculating rotations, but it was always whole numbers, on one axis, some multiple of 90 degrees and other animations created in the same manner functioned perfectly every time. I got tired of fooling with it and just shelved the idea of using it for anything involving any manner of precision.

I’m not exactly certain what you’re doing, but on the other hand I’m not very surprised that you don’t get 100% precision - I know that Unity could do better job at it. Main problem is Euler to Quaternion conversion (and how it converts tangents), because animations are stored and played as quaternions. Conversion back from quaternion to euler might add something to inprecission too.

It would be good if you could make a small repro-project and submit it as a bug - I would like to investigate it later.

You might be a bit more lucky by creating a separate animation curve (which animates only euler.X component) and sampling it manually and then setting as rotation on your object. I wouldn’t give 100%, but I know that no conversion or modification on tangents would be involved.