• 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 smirlianos · Jun 17, 2013 at 08:03 AM · animationspeedplaylengthbackwards

[Unsolved] Playing animation backwords [Unsolved]

Hello!

I try to make my player play the "walk" animation backwords when the user presses "S". I tried this, but it only plays the animation once. Any help??

 function Update () {
     if(Input.GetKeyDown(KeyCode.S))
     {
         animation["walk"].speed = -1;
         animation["walk"].time = animation["walk"].length;
     }
     if(Input.GetKey(KeyCode.S))
     {
         animation.Play("walk");
     }
 }
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

Answer by DricoJD · Jun 17, 2013 at 12:00 PM

An Animation can be scripted backward, it would be a function of a mere connection of strings and variables. My best bet and simple way of getting around this is either make a seperate animation or go to the animation setting and set it to ping pong. If this does not work this way you can always make a script to change animation settings via a script; comment if you want me to write it for you. Also if this way I suggested work can you thumbs up :)

Comment
Add comment · Show 13 · 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 smirlianos · Jun 17, 2013 at 02:08 PM 0
Share

Can you wrie the script please?

avatar image DricoJD · Jun 17, 2013 at 02:15 PM 0
Share
 hand.animation["walk"].speed = -1; 
 
 hand.animation["walk"].time = -1;
 hand.animation["walk"].length;
 
 hand.animation.Play("walk");

thumbs up

avatar image smirlianos · Jun 17, 2013 at 04:31 PM 0
Share

How will I add this to my script??

avatar image DricoJD · Jun 17, 2013 at 04:52 PM 0
Share

get rid of all your script contents that is presented in your question - and just paste this inside the as a new function as so:

 function update()
 {
 hand.animation["walk"].speed = -1; 
  
 hand.animation["walk"].time = -1;
 hand.animation["walk"].length;
  
 hand.animation.Play("walk");
 thumbs up
 }

Please thumbs up as it keeps me running on my oil!

avatar image smirlianos · Jun 17, 2013 at 05:49 PM 0
Share

It doesn't work. What's "hand.animation["walk"].length;" doing alone??? Anyways, I want it to play when the player walks back, not always!!

P.s. Calm down with the "thumbs up"!!!! It doesn't work like youtube! :) P.s. I don't think hand. is neccesary.....

Show more comments

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

15 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

I am attempting to play an animation in reverse and slow it down, But it only seems to play forwards. 2 Answers

Animation Stop and Stay 1 Answer

Using Animator, How To Play an Animation Backwards 1 Answer

Animation ["1"].speed = 0; Doesn't work 2 Answers

Why is Animation Not Playing in Reverse? 2 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