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 slgooding · Aug 01, 2012 at 01:29 AM · animationruntimekeyframesbaked

Bake Animation during Run-time in Unity

I'm wondering if it would be possible to bake an animation to a AnimationCurve during runtime?

I've attempted to assign keyframes on-the-fly using a counter variable as keyframe[counter], but KeyFrame doesn't support iteration (IEnumberable). Is there any way to do this without having to manually type out keyframe[#] for each one?

Is there a better way to bake transformations?

I understand that I could keep track of values over time, but that would also require that "time" be running in order to play it back. Unfortunately I need to have the TimeScale at 0. I currently grab all the animation clips in the scene, and then use a slider where I can scrub the playback, where the slider sets the frame number for each clip. That is for animations created ahead of time. I need to be able to do this with dynamic animation created while the game is running. Hopefully that makes sense.

Thanks!

Comment
Add comment · Show 1
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 slgooding · Aug 01, 2012 at 02:51 PM 0
Share

@bunny83 I think you may have helped me understand something that I was doing wrong. I'll post back. If it doesn't work I'll probably try the Add$$anonymous$$ey functions.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Aug 01, 2012 at 02:26 AM

I would think you would use AddKey and related functions: http://docs.unity3d.com/Documentation/ScriptReference/AnimationCurve.AddKey.html Is that not working?

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 · Aug 01, 2012 at 02:39 AM

The most flexible way to set / change KeyFrames in an Animationcurve is to use AnimationCurve.keys. You have to copy them into a local array, modify the array and assign it back.

I'm still not sure why you need to create them on-the-fly. You can Sample an animation at any time you like. You can drive the animation time manually if you want.

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to assign "data" in script at runtime 0 Answers

Which is better: script or animation (which needs to change with scripting)? 1 Answer

Can I make animations snap to a frame? 1 Answer

Make ball flip around cube... 0 Answers

runtime: script variable not processed as demanded 1 Answer


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