Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Sobriquet · Oct 04, 2011 at 09:00 PM · animationreversesubtract

Flip back a frame

Hello!

This one is probably easy but I am not sure how to frame the question so I'm not finding the answer. Basically, I am trying to make animation poses advance forward one frame or reverse back one frame depending on which button is touched. I have forward down easy, basically it's state++; if (state == 1){ animation.Play("1"); } if (state == 2){ animation.CrossFade("2"); copy pasta copy pasta.
Now, how do I create a state-- if you will? I thought that would work but Unity just whistles and smirks at me. I've tried +-1 but this gets me that expressions error. I've tried looking it up but haven't gotten very far. A little nudge in the right direction would be most helpful! 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 asafsitner · Oct 04, 2011 at 09:05 PM 0
Share

Take a look at the animation's play speed property, maybe you could set it to -1/1 for a single frame and back to 0?

http://unity3d.com/support/documentation/ScriptReference/AnimationState-speed.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by ibrews · Dec 03, 2013 at 05:44 PM

hey I know this is a super old question, but I just faced a similar problem and here's the solution I came up with-- hope it helps someone! The short answer is: use the += and -= expressions to change the value of 'state'.

 
var state = 0;
function Update () {
    if (Input.GetKeyDown(KeyCode.RightArrow)) {
    state += 1; 
    Debug.Log(state);
    }
    if (Input.GetKeyDown(KeyCode.LeftArrow)) {
    state -= 1; 
    Debug.Log(state);
    }
if (state==1) {
    animation.CrossFade("1",.2);
    animation["1"].speed = 0;
    animation["1"].weight = 1.0;
}
if (state==2) {
    animation.CrossFade("2",.2);
    animation["2"].speed = 0;
    animation["2"].weight = 1.0;
}
if (state==3) {
    animation.CrossFade("3",.2);
    animation["3"].speed = 0;
    animation["3"].weight = 1.0;
}
etc. etc.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Nav mesh agent moves backwards - How can I rotate gameobject without using an empty 1 Answer

Help With Animation Play Back - Reverse 1 Answer

How to Record or Play an animation backwards 1 Answer

Why is Animation Not Playing in Reverse? 2 Answers

Unity 5. Reverse animation play ? 4 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