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 Bunnybomb7670 · May 08, 2014 at 10:25 PM · animationanimatorstates

Animations - Can you cut them?

I am currently working on a 2D game project and I am running into a few small issues with animation. I am trying to use the Animator to create basic states for the character, states such as Idle, Walking, Running and Jumping. I have managed to do this however I would like to know if it is possible to implement a system what can cut an animation halfway, if you look at this project : Project you will notice how if you tap the arrow keys, the character takes an entire step to the side. I would like to know, is it possible to prevent this, from my experimentation I have found that state conditions are only checked upon starting the animation, while playing it does not check the state conditions to see whether or not it can keep playing.

I am using this script to manage the states :

 public class AnimManager : MonoBehaviour 
 {
     Animator anim;
 
     public float fakeinput;
 
     public float threshold;
 
     public bool moving;
     public bool left;
 
     public int movingHash = Animator.StringToHash("Moving");
     public int leftHash = Animator.StringToHash("Left");
 
     void Start()
     {
         anim = GetComponent<Animator>();
     }
 
     void Update()
     {
         float move = Input.GetAxis("Horizontal");
 
         anim.SetFloat("Speed", move);
 
         //move = fakeinput; // FAKE INPUT FOR EASE OF ANIMATION TESTING
 
         if (move <= 0.0f + threshold && move >= 0.0f - threshold)
         {
             moving = false;
         }
         else
         {
             moving = true;
         }
 
         anim.SetBool("Moving", moving);
 
         anim.SetBool("Left", left);
     }
 }

Is it possible for me to cancel or cut / blend back to idle if the animation is playing and the " moving " boolean is marked as false?

Any help would be massively appreciated.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by hippysniper · May 08, 2014 at 11:56 PM

use animation.blend http://docs.unity3d.com/Documentation/ScriptReference/Animation.Blend.html

 if(!moving){
 animation.Blend("idle",1,0.1)
 }
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 Bunnybomb7670 · May 09, 2014 at 06:45 AM 0
Share

I am using the "Animator" class though, I cannot use that function. Is there an alternative on the Animator class which I am not seeing?

avatar image
0

Answer by Sparta5_6 · May 08, 2014 at 11:53 PM

Why don't you just delete the animation keys?

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 Bunnybomb7670 · May 09, 2014 at 06:51 AM 0
Share

I do not have much experience with the Animator system so, could please you explain more what you mean?

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

22 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

Related Questions

How to make a transition animation, intermediate animation between two main states 0 Answers

Animation Vs Animator 2 Answers

How do I Change States in Animations? 1 Answer

2D Animation does not start 1 Answer

Animation Finishes Sequence Before Going To Next Animation 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