Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 MKamen · Jul 04, 2017 at 11:40 AM · animationfbxkeyboard input

Change character animation when different control is pressed?

Hello guys! My child is doing school project in Unity and she asked me to help her with this one. She created landscape and imported prefabricated free horse from Unity store (yes, it's project which includes horse riding, but without human, horse is character). She imported the horse and we solved controlls (forward, backward, lef, right, jump). Horse animation is in fbx format and I can change his default behaviour but don't know how to change animation when key is pressed. I want to change from idle to "trot" when any of wsad keys are pressed, "run" when holding shift and "jump" when space is pressed. Can someone help? Is it possible from fbx file to call out different animations regarding pressed key?

Thanks in advance.

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 SohailBukhari · Jul 04, 2017 at 12:27 PM

Open up the Animator window. This can be found at the top under "Window" and "Animator" (I believe it has no hotkey associated with it.) When this opens, select your Game Object in your Hierarchy. If the Animator has an orange box with the name of your animation in it, this is why it is auto-animating. The way that I fix this is that I right click inside the Animator window and create a new state and I call it Idle. Inside Idle I don't assign any animations at all. Right click Idle and set it to the default state, which should then make it orange. From here you want to right click on Idle again to create a transition, at this point an arrow will appear underneath your mouse cursor and you will want to use it to click on your other animation state (the one that was originally orange.) This tells the Animator you want to go from Idle (where no animation is playing) to a state where an animation is playing. In the bottom left of your Animator window is a box called "Parameters", go ahead and click on the + on the right side of that box and add yourself a Trigger which you can name anything you want. Then click on your transition arrow from Idle -> Whatever Animation and check the inspector. Change the Condition from "Exit Time" to your Trigger. You will also want to set a transition FROM your Animation TO Idle so that it exits after the animation is complete (and you can use the default settings for a transition for that, no new triggers required.)

After you do that block of text, go into your code and inside the check for input write GetComponent().SetTrigger( "NameOfYourTriggerYouMade" );

 public bool animation_bool;
           void Update()
                      {
               if(animation_bool == true)
                      {
    GetComponent<Animation>().SetTrigger( "NameOfYourTriggerYouMade" );                         }
             if(Input.GetButtonDown("space"))
                      {
                animation_bool = true;
                      }
                 }

For more information visit animation play on key press

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 MKamen · Jul 05, 2017 at 06:41 AM 0
Share

Thank you very much!

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

163 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 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 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 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 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 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 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 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 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 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 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

From Maya to Unity FBX problems 3 Answers

Character Change its Position When Animation Apply on It 0 Answers

Blender stops exporting after certain animation 0 Answers

Rigidbody gravity X Generic Mecanim Additive Move-Forward Animation 0 Answers

Is skinning weight dependent on animations or on base model? 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