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 TakeTwo · Jun 10, 2015 at 04:48 PM · animationjavascriptbeginnerswitching

Problems switching animations | Please answer

First off I am a beginner with Unity and would like a simple answer with not much involved. My problem is that I have two animations: run and idle. I have parented a knife and a hand to an empty game object. I have linked the animations to the empty game object; "weapon". I have made a quick javascript which makes the run animation play when I hold down "w". When I release "w" it will play the idle animation. My problem, yes, again, is that the animations run fine but after I stop walking the idle animation plays in whatever position the GameObject was last at rather than the starting position of the animation. However, when I press "w" again, the run animation works fine with the weapon going back to the proper position.

Here is my script:

    function Update()
     {
      if(Input.GetKeyDown("w"))
      {
       // Plays the animation - stops all other animations
       GetComponent.<Animation>.Play("runninganim", PlayMode.StopAll);
      }
      if(Input.GetKeyUp("w"))
      {
      GetComponent.<Animation>.Play("ambientanim", PlayMode.StopAll);
      }
     }

Please help. Here are some images.

1: http://answers.unity3d.com/storage/attachments/47775-screen-shot-2015-06-07-at-20251-pm.png 2: http://answers.unity3d.com/storage/attachments/47774-screen-shot-2015-06-07-at-20159-pm.png

Comment
Add comment · Show 5
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 TakeTwo · Jun 11, 2015 at 06:20 AM 0
Share

Bump. Please

avatar image Wolfdog · Jun 11, 2015 at 06:40 AM 0
Share

Saying 'please' won't attract much attention. - just a side note.

You should upgrade to the new animation system - it's the future of Unity. It's even easier to use. As for this system, I can't help much as I never got to learn it. (I'm quite a recent Unity user).

avatar image TakeTwo · Jun 11, 2015 at 06:55 AM 0
Share

As for the new animation system, I have used the animation window to make the clips, and there is an error in my code saying that I need to set it to legacy. Do I use the Animator window (not animation) to make my clips ins$$anonymous$$d of coding? BTW I don't know how to use it.

avatar image Wolfdog · Jun 11, 2015 at 07:03 AM 0
Share

No, you still create animations with the Animation tab, and then you drag the animations from your assets to the Animator. As for a tutorial, just visit the unity site. I watched some YouTube vidoes and grasped the concept in under an hour.

If you're not on Unity 5, then I recommend upgrading.

avatar image TakeTwo · Jun 11, 2015 at 07:18 AM 0
Share

Thanks. :)

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

In-depth Animation and Audio guide for Enemy AI? 1 Answer

How would you reccommend adding the jumping animation to my script? 0 Answers

Play a simple animation once on key press 3 Answers

Animation doesn't work 1 Answer

Begginers question, Simplifing a script, opening two doors with 2 overlapping triggers. 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