- Home /
Making transform based animation "snap" when mixing with sprite based animation
I'm working on a 2D game. I have a sprite for the players body which always displays the same image, but the rotation and position is animated. The player has 2 legs, which use frame based animation (5 different images/frames).
I'm trying to build my animations using the Animation and Animator tabs. I have them all built and working with one exception:
The animation that changes the position and rotation is "smooth" between key frames. The animation that changes the sprite images just changes on each frame, not gradually between frames.
Now, obviously I can't make the sprites change gradually, not without some advanced image morphing code... So how do I get the transform based animation to only update at each key, instead of smoothly?
I'm hoping it is just a setting I can change, but I've changed everything I can think of ("Free", "Smooth", "Flat", "Broken" curve related settings), and nothing is producing the results I'm looking for. My animation looks weird if part of it is smooth and the other part is jumpy/frame-based.
Answer by shopguy · Oct 04, 2014 at 05:10 AM
Guess I just didn't look hard enough before asking, sigh... for future readers...
You have to click on "Curves". A little tab/button currently in the lower left area of the Animation view. You can switch between Dope Sheet and Curves. Once I found the Curves view, it was pretty obvious. Just click a point on the chart, then drag the little end points until the smooth rolling hills looking lines change to 90 degree angles... like steps.
Kind of a crummy solution all around, but to fix my other issue with the Rotation animations not respecting the curve, I created this class and animated the public Rotation property instead. Sucks because I can't preview my animation clips in the editor now, without running the game.
public class RotationAnimator : MonoBehaviour {
public Vector3 Rotation;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.localEulerAngles = Rotation;
}
}
In my defense, it didn't help that the docs don't match the UI (at least not my UI, on Windows): http://docs.unity3d.com/$$anonymous$$anual/EditingCurves.html -- they show a different method to get to the curve editing, I don't have that option.
Although, this is working for almost everything, Rotation.z is still animated smoothly, even though my "curves" are 90 degree angles (straight lines). All of the other properties work correctly, but no the Rotation.z animation. I may create a small sample project to recreate a submit a bug report, if nobody has a better answer.