Jump to content
  • Advertisement
Sign in to follow this  
cebugdev

What is Unity Animation Curve formula

Recommended Posts

Posted (edited)

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);

 

Edited by cebugdev

Share this post


Link to post
Share on other sites
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.

 

Share this post


Link to post
Share on other sites

 

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!