• 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 jprice2 · Jan 13, 2021 at 04:15 AM · animation3danimator controllerglitch3d model

How to fix multiple character animations playing at the same time during a run animation?

I have imported my character model from Blender into Unity, with the animations functioning properly in the preview screen. I followed many tutorial videos about how these animations could be assigned to different character movements, however I encountered a problem. My "Idle" and "Jump" animations work fine, but my "Run" animation glitches and plays the run and jump animations at the same time, as seen in the attached clip. I have assigned two parameters to my animations, and set these to my game in my code:

speed - (float, set at 0.0)

grounded - (bool, set unticked)

P.S. The name of my character model is "solidified body and fixed belt character"

P.S. I have mapped all animation transitions in accordance with multiple videos and i'm pretty sure they are correct. For example, the "Run" to "Jump" transition has grounded set to false, and speed set to greater than 0.1 (as seen in the attached image).

If anyone has any suggestions it would be much appreciated. I'm new to Unity so it would also help if you could give as much detail in your answers as possible. Thanks :)

Link to video of glitching character: https://youtu.be/D-bgSnLvU14

CODE:

 public class Capsule : MonoBehaviour
  {
      public CharacterController _controller;
      public Transform cam;
      public float speed = 12f;
      public float gravity = -9.81f;
      public float jumpHeight = 3f;
      public float turnSmoothTime = 0.1f;
      float turnSmoothVelocity;
  public Transform GroundCheck;
  public float groundDistance = 0.4f;
  public LayerMask groundMask;
  Vector3 velocity;
  
  bool isGrounded;
        
  public Rigidbody rb;
  public Animator anim;
  
  // Start is called before the first frame update
  void Start()
  {
      _controller = GetComponent<CharacterController>();
      rb = GetComponent<Rigidbody>();
  }
  // Update is called once per frame
  void Update()
  {
      isGrounded = Physics.CheckSphere(GroundCheck.position, groundDistance, groundMask);
      if(isGrounded && velocity.y < 0)
      {
          velocity.y = -2f;
      }
      float h = Input.GetAxisRaw("Horizontal");
      float v = Input.GetAxisRaw("Vertical");
      Vector3 direction = new Vector3(h, 0, v).normalized;
      if (direction.magnitude >= 0.1f)
      {
          float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y;
          float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
          transform.rotation = Quaternion.Euler(0, angle, 0);
          Vector3 moveDir = Quaternion.Euler(0, targetAngle, 0) * Vector3.forward;
          _controller.Move(moveDir.normalized * speed * Time.deltaTime);
      }
              
      if (Input.GetButtonDown("Jump") && isGrounded)
      {
          velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
      }
      anim.SetFloat("speed", Mathf.Abs(h+v));
      anim.SetBool("grounded", _controller.isGrounded);
      
      velocity.y += gravity * Time.deltaTime;
      _controller.Move(velocity * Time.deltaTime);
  }


[1]: /storage/temp/174111-animator-controller.png

animator-in-inspector-window.png (66.4 kB)
animator-controller.png (227.2 kB)
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
0

Answer by jprice2 · Jan 14, 2021 at 04:49 AM

Could it be because my animation type is "Generic" not "Humanoid"?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Root Movement with Additive Layers 0 Answers

My animation plays in scene but not in animator preview or in game. 0 Answers

Why is the rotation missing when I animate? 1 Answer

How do I activate an animation when a gameobject enter the Collider of the other animated object 2 Answers

Can I animate 3d model like 2d sprite animations? 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