- Home /
How do i redraw an entire curve with the mouse (as opposed to one single keyframe redraw)?
When editing an animation curve in unity curve editor, what happens is that the mouse selects one single keyframe that you can then move around across both x and y axes. This means that you can only modify one single keyframe at a time with one mouse drag.
I would like to: 1- be able to modify keyframes values only across the y axis (up down but no change in position left right) so that the modify key frame keeps its original x axis value no matter what. 2- Be able to drag my mouse pointer across multiple keyframes and have them modify their Y axis values accordingly. In effect redrawing the curve with my mouse pointer as if with virtual a pen.
How could I achieve that? Is there a setting somewhere I can change? Or Should I implement my own curve editor (if yes how?)?
I declare my curve this way:
public AnimationCurve _pitch;
and I populate it this way:
int T = 100;
ks = new Keyframe[T];
int i = 0;
while (i < ks.Length)
{
ks[i] = new Keyframe(i, Mathf.Sin(2* Mathf.PI/T *i) );
i++;
}
_pitch = new AnimationCurve(ks);
@tw1st3d I have edited my post to answer your comment. Hopefully it makes sense. It is visually simple but hard to describe by words.
What you are asking for is not a functionality of the editor, so yes you will have to implement it yourself.
The process of taking a set of points and drawing a curve that passes through them is known as http://en.wikipedia.org/wiki/Curve_fitting. It is non-trivial math and may not always give you the results ou expect.
Start that that wiki page, then google "curve fitting" for more information.
@jeff $$anonymous$$esselman I do not actually need curve fitting i.e I do not need any post processing of my values once they are modified. And I do not need any processing to modify them either as I only want the mouse pointer y-values to be the new values. Just straigth one to one mapping. Not doing any computing. How do I implement my own curve editor with mouse click drag detection?