Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Inuous · Feb 20, 2011 at 10:22 PM · animationcurvetangent

How can I convert AnimationCurve.in/outTangent to an angle

I need to convert the tangents of a keyframe to angles for a custom animation panel I'm developing. Any help appreciated. I can't seem to find a correlation between the tangent (in or out) and the angle used to display the tangent handles in the standard animation panel / animation curve editor.

Thanks

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by MaDDoX · Jul 23, 2012 at 10:31 PM

The angle is calculated counter-clockwise, based on the tangent of the provided float like Bunny83 said - so a simple Mathf.atan should suffice. If you're trying to emulate "step" tangents, you're out of luck, even a value of 0 for the first key's out-tangent and 6000 (or -6000) for the second key's in-tangent won't work the same as what Unity does in its own animation window. My suggestion in this case is to simply add an auxiliary keyframe with a high fractional time value, close to the second keyframe. So you'd have something like this:

 var key    = new Keyframe (0, 0, 0, 0);
 var auxkey = new Keyframe (0.9999, 0, 0, 0); 
 var key2   = new Keyframe (1, 1, 0, 0);

Unity doesn't care about anything after the fourth decimal, so this would probably work. Good luck!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Bunny83 · Feb 20, 2011 at 11:15 PM

Well, i just thought the tangents were in degrees when i look at the samples but it's just the tangens of that angle. I copied the sample from Keyframe.inTangent and tried some values. Just make only two keyframes, set the second inTangent to "1" and run the game. Open the curveeditor for the generated curve. If you zoom in properly you will see the tangent have 45. tan(45) == 1.0f

Since you can zoom both axis independently the viewed angle changes. To zoom use the mouse wheel. To zoom x-axis only hold CTRL, to zoom y-axis only hold SHIFT. When you bring both axis to the same scale it will show the actual angle (according to the tangens value).
I'm quite happy with the built in curve editor but if you think you can improve it or if you need some special treatment, go on.

If you need more help just ask, but i guess if you try something like that you know what you're doing ;)

good luck

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How can I set my Animation Curve's Tangents to Flat in script? 0 Answers

How can I get an accurate bounding rect for an AnimationCurve 1 Answer

What is the length of the Keyframe tangent? 0 Answers

How do I modify a keyframe/curve's tangent in code? 2 Answers

How do I scale an animation curve by time and value while retaining my tangent values? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges