- Home /
Access curves presets from c#
Hi all,
I was wondering if it was possible to have access from code to the default curve presets you can see when opening the curve editor.
Thank you
Comment
Best Answer
Answer by DerWoDaSo · Feb 18, 2014 at 01:08 PM
As far as I know, they are not available. But they should be easy to set up.
Something like:
public static AnimationCurve CreateStraightCurve()
{
AnimationCurve curve = new AnimationCurve();
curve.AddKey(new Keyframe(0, 1));
curve.AddKey(new Keyframe(1, 1));
return curve;
}
public static AnimationCurve CreateLinearCurve()
{
float tan45 = Mathf.Tan(Mathf.Deg2Rad * 45);
AnimationCurve curve = new AnimationCurve();
curve.AddKey(new Keyframe(0, 0, tan45, tan45));
curve.AddKey(new Keyframe(1, 1, tan45, tan45));
return curve;
}
public static AnimationCurve CreateEaseInEaseOutCurve()
{
AnimationCurve curve = new AnimationCurve();
curve.AddKey(new Keyframe(0, 0, 0, 0));
curve.AddKey(new Keyframe(1, 1, 0, 0));
return curve;
}
You can also use the static functions of AnimationCurve: Linear and EaseInOut to create standard curves.
Your answer
Follow this Question
Related Questions
moving forward after bazier curve 1 Answer
Text along a curve 2 Answers
Multiple Cars not working 1 Answer
2D simple road system with curves and intersections 0 Answers