Performance of AnimationCurve

I recently discovered the AnimationCurve class and immediately plugged it into a vehicle as the acceleration logic (accelerationCurve.Evaluate(currentSpeed/topSpeed)) which in simple tests works wonderfully.

What I’m wondering is how (resource) expensive are AnimationCurves? Is there a good argument why not to use them this way?

It’s a good question, and the answer is that it’s probably reasonably cheap. Most curve evaluation routines boil down to just a few multiples and adds. Animation systems will often evaluate a curve for each component of each joint in the skeleton of every character. That’s a lot of curves!

In your case, you should be totally fine using animation curves for cases like this. Use curves where they really benefit you and don’t use them where a Lerp would be just as good. If you do that, the performance impact should be negligible.

Plus, assuming that they are using bezier constants, they probably bake them “on modification” and in that case that would just be a succession of at^3 + bt^2 + c*t or something close. Probably very fast, mainly when you know how handful it is in editor