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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by wkmccoy · Mar 06, 2013 at 03:13 PM · animationspeedeventenabledanimationevent

Animation control using Events and .enable

(unity 3.5.6 c#)

I have a menu to control the flow of an animation, which is stopped several times using the Animation event to call out to a function that sets the .enabled = false;

This allows me to setup animations that can be controlled for learning a process. The features I have working (with a small hicup) are to allow the learner to move backwards and forwards in the animatin stopped by the Animation Event Markers. So each animation can have X steps (markers) and the user can start the animation, see 1 step, and then get some info, then using a button to continue the animation or reverse it.

All works, but when hitting REVERSE or speed=-1 I have to hit that button twice the first time, but if I keep hitting it, it works fine. So its like the reverse was being ignored the first time and it hit the same Event and stopped, but when I hit it again, it then plays backwards and goes to the previous event.

(confused, sorry, not a great writter)

I have setup 2 scripts, one on the Animation Object, and another on an object you click to start the menu items, which control the animation.

Here are examples of what I have (each event has its own function just for controll options)

Note the name of the clip is found in the AWAKE by doing foreach in the AnimationState

AnimationController.cs

 void HaltAnimation01() {
 animation[DaAnimationCip.name].enabled = false;
 }

then the script with the GUI that has a play button, up and down arrows to move 1 step forward or backward. The UP and Down Arrows are what is not working on 1 click, but takes 2 to make it catch.

SequenceTrigger.cs (partial)

 if (GUI.Button (new Rect(0,0,32,32),GUIContent.none, "UpArrow") {
    WAR_FPC.animation["test1"].speed = -1;
    WAR_FPC.animation["test1"].enabled = true;
 }

I have tried putting the -1 after the enabled, and even tried putting a play after it, but it still does the same thing.

If animation has gone to event 3, I hit the UP Arrow to reverse the animation to Event 2. Its seems to play to Event 3 again and stop (realy quick blip) I press the UP arrow again, and it reverses to Event 2, like I wanted, but it takes 2 presses to start the -1 flow. But... if I keep pressing UP, it works on the first press, so it seems the initial reversing of the flow is not being set correctly or in the correct way? It also does this when I press DOWN after getting the reverse to play same code, but Positive 1.

How can I make it reverse on just 1 click (rather than 2)?

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
0
Best Answer

Answer by wkmccoy · Mar 08, 2013 at 02:37 PM

Ok, I got a better play back response out of using the .speed = 0 rather than .enabled = false (and then true) So setting the speed to 0, then 1 or -1 creates a smooth flow and does not force a 2 click to make it reverse direction. Not sure if there is a hit on performance whie the animatin is still, but so far its smooth and repsonsive.

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

10 People are following this question.

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

Related Questions

Ignore "AnimationEvent has no Receiver" errors 0 Answers

Error in AnimationState.cpp Line: 307 1 Answer

Animations couldn't be found but still plays 0 Answers

is it possible to save over animation clips and keep events? 1 Answer

Animation Event Remote Procedure Call 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