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 danhanly · Jun 20, 2012 at 01:30 PM · animationbuttontimeanimationclipanimationstate

Trying to manage an Animation. AnimationState.time doesn't adjust the animation

I have a sphere moving from left to right by use of an animation. To the interface, I've added a button that will advance the animation by a set interval called delta.

Below is my moveObject script which is attached to the Sphere.

 var objectAnimation:Animation;
 function Movement(delta:float){
     animation[objectAnimation.clip.name].time += delta;
 }

This function is called from the button within it's button press method as below:

 moveTarget.GetComponent(MoveObject).SendMessage("Movement", 1.0);

A Debug.Log of animation[objectAnimation.clip.name].time shows that it is indeed changing every time the button is pressed. Say for instance, the delta is 1, in my tests, every time the button is pressed, the Debug.Log returns 1, then 2, then 3 etc. However, the animation itself does not advance, the Sphere stays in the same place all the time.

What am I doing wrong here?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Jun 20, 2012 at 02:23 PM

The AnimationState have to be enabled and need to have some weight set. The weights of all active animation states are combined and normalized. If you have two animations with a weight of 1.0 each, it will result in each animation get's 0.5 weight.

If you call Play() it actually does this for you. It enables the state and set it's weight to 1.0. CrossFade will enable it and slowly increase the weight and decrease the weight of the old one.

The time usually advances automatically, so if you want to set the time manually, you might want to set the speed to 0.0

You can also use Animation.Sample to sample the animation manually at a certain point.

Comment
Add comment · Show 1 · 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 danhanly · Jun 20, 2012 at 04:03 PM 0
Share

Perfect. Thanks!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

C# Scrubbing back through an Animation in script 1 Answer

Moving Player only during part of an animation 1 Answer

Simple state switching to mouse over & pressed requires 2 animation clips with some parts duplicated? 1 Answer

How to Serialize an AnimationState 0 Answers

Toggle between animation states with UI button 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