🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

What is Unity Animation Curve formula

Started by
4 comments, last by cebugdev 5 years, 2 months ago

hi all,

 

im trying to port a unity UI code into a straight C++ OpenGL rendering, and i am in the part where i need to integrate the animation/transition part of the UI.

Im not really much of a unity developer, but i found out that animations in unity uses some form of a curve where you can set control points(keyframe) for interpolation, etc.

Do you guys know what the formula used for animation curve in unity?
doing a little google myself returns the same two stackoverflow result and the codes samples are hard to comprehend.

 

basically, what im trying to achieve is, to simulate unity's animation curve and get current value based on time, 

something like

interpolator.AddKeyframe(time, value);

int value = interpolator.GetValue(time);

 

Advertisement

Not really a math question, but a question that the Unity Programmers Manual should be able to answer.

I am also not a Unity programmer, but I'd expect the interpolator to take a parameter wrt how to interpolate. Eg one may want straight lines between points, or some fluent spliney thing. The interpolator class looks like the logical candidate to have that information available. Likely it also has a list of known interpolation types, which is then useful to figure out what your program is doing.

 

If you just want something like Unity, without necessarily being exactly the same, then you should probably start here.

Is this one of the posts you are referring to?

https://answers.unity.com/questions/464782/t-is-the-math-behind-animationcurveevaluate.html

My current game project Platform RPG

 

16 hours ago, Alberth said:

Not really a math question, but a question that the Unity Programmers Manual should be able to answer.

I am also not a Unity programmer, but I'd expect the interpolator to take a parameter wrt how to interpolate. Eg one may want straight lines between points, or some fluent spliney thing. The interpolator class looks like the logical candidate to have that information available. Likely it also has a list of known interpolation types, which is then useful to figure out what your program is doing.

 

yes the Unity manual do have some clue but i found the answers i need in the .anim file of each unity project.

Anyways, Ive' got it working! just posting here  incase somebody needs to do what i am doing.

i followed the answer by SuperPingu at this link: 

https://answers.unity.com/questions/464782/t-is-the-math-behind-animationcurveevaluate.html

with the values for time, value and tangents coming from Unity editor and for their .anim text file, the information I need can be found in the 'm_EditorCurves' section of the file.

Since like what I said, i am porting a Unity project to OpenGL C++, this is just what i need!

Thanks for those who replied, upvote for all

This topic is closed to new replies.

Advertisement