x


How to access AnimationCurve at runtime

Unity introduced AnimationCurve as a runtime class. But there is no doc or any sample on accessing it while the game is running. I'll be greatful if someone can to me how to do. Thanks.

more ▼

asked Mar 30, 2011 at 03:10 PM

mcwind gravatar image

mcwind
83 19 16 22

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

You can't get AnimationCurves from an AnimationClip. Strangely/sadly you can only set or add curves.

You'll have to keep track of any curves you create procedurally, in a dictionary for instance.

more ▼

answered Mar 31, 2011 at 12:21 PM

Statement gravatar image

Statement
25.8k 76 108 238

Yes, now I saved the AnimationClipCurveData to disk and created a curve at runtime with it.

Apr 07, 2011 at 03:00 PM mcwind
(comments are locked)
10|3000 characters needed characters left

What way do you intend to use it?

Here's an example usage for animating a light turn on through Evaluate. You edit the AnimationCurve in the inspector. You can also give it some simple default value through Linear and EaseInOut.

var intensity : AnimationCurve;

yield AnimateIntensity();

function AnimateIntensity() {       
    var duration = intensity[intensity.length - 1].time;
    var timer = 0.0f;
    while (timer < duration) {
        timer = Mathf.MoveTowards(timer, duration, Time.deltaTime);
        light.intensity = intensity.Evaluate(timer);
        yield;
    }
}
more ▼

answered Mar 30, 2011 at 03:19 PM

Statement gravatar image

Statement
25.8k 76 108 238

I can process the curves in a editor script to meet my requirement. I just intend to know more about the class. It's a runtime class but can't be accessed at runtime, very strange.

Mar 31, 2011 at 03:09 AM mcwind

I mean "Access" as obtaining it from a clip at runtime, not just assigning it in inspector as a static reference.

Mar 31, 2011 at 03:14 AM mcwind
(comments are locked)
10|3000 characters needed characters left

If you want to edit at runtime an animation curve,check this out:
http://u3d.as/content/rus-artur-pfa/runtime-curve-editor

more ▼

answered Oct 12, 2013 at 08:11 AM

Varaughe gravatar image

Varaughe
81 3 3 3

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4683
x573
x104

asked: Mar 30, 2011 at 03:10 PM

Seen: 2684 times

Last Updated: Oct 12, 2013 at 08:11 AM