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 bhviid · Apr 24, 2014 at 02:46 PM · animatoranimation controllerstutter4.3

Movement stutter when Animator is activated in 2D project (4.3)

Hi,

In my top-down 2D game, whenever I activate the Animator on my player (in the inspector), the movement of the player begins to stutter. When the Animator component is deactivated his movement is really smooth.

It is quite strange as there is no significant change in the framerate when there is stuttering or fluid movement. According to the profiler does the Animator.Update() only account for anywhere between 1.5% and 2.5% of the CPU usage when the movement is stuttering.

The player consist of eight different sprites (body, head, 2x upper arm, 2x lower arm, 2x hand) that are animated using curves in the Dope Sheet. All the sprites (limbs) are nested under an empty gameobject that contains a rigidbody2d component and a polygon collider (as well as some scripts). The limbs only have a SpriteRenderer attached.

The Animation Controller contains three different animations, idle, walk and shoot. They are made up of somewhere between 5 and 7 different animation curves that mostly changes the rotation of the limbs (you can see the dope sheet for the walk animation in the attached image). They transition between each other based on the player speed and a trigger (when the player shoots).

I have tried to set the Fixed Timestep to 0.01 instead of 0.02, which helped a bit. It is not as good as I would like it to be, and I'm a bit uncomfortable to set it much lower than that.

The player movement is controlled using AddForce() in FixedUpdate() as shown below, if that should be of any importance.

It seems strange if Unity has trouble handling this, as it does not appear to be very computational demanding. Does anyone have a suggestion as to how I can get proper movement using this animation system?

Also, check out this video for a comparison between the movement when the animator is on and off: https://www.dropbox.com/s/ko68hlazdt9jixr/comparison.mov (the player limb graphics are placeholder).

 void FixedUpdate () {
 
         device = InputManager.ActiveDevice; // we're using InControl
 
         float h = device.LeftStickX;
         float v = device.LeftStickY;

         if(gameObject.rigidbody2D.velocity.x < maxSpeed)
             gameObject.rigidbody2D.AddForce(Vector2.right * h * maxSpeed * force * Time.fixedDeltaTime);
         
         if(gameObject.rigidbody2D.velocity.y < maxSpeed)
             gameObject.rigidbody2D.AddForce (Vector2.up * v * maxSpeed * force * Time.fixedDeltaTime);
 
         if(device.RightStickX != 0 ||  device.RightStickY != 0)
             angle = new Vector3(0.0f, 0.0f, (Mathf.Atan2(device.RightStickX*-1, device.RightStickY) * Mathf.Rad2Deg));
         
         transform.localRotation = Quaternion.Euler(angle); // this should probably be in Update(), but it does not seem to cause any trouble atm
     }



alt text

player-walk.png (45.0 kB)
Comment
Add comment · Show 2
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 ZenithCode · Apr 24, 2014 at 08:26 PM 0
Share

The problem is not the animator. You have 2 forces acting on the same character. You need your animations to NOT move the character. I think you can easily do this by turning off 'Root$$anonymous$$otion' on the animator.

avatar image bhviid · Apr 24, 2014 at 08:31 PM 0
Share

Hi ZenithCode,

I have Apply Root $$anonymous$$otion deselected in the Animator, so that is not the problem, unfortunately.

I have tried selecting Animate Physics, which helps on the uneven movement speed, however there is still a jitter/shaking effect whenever the player moves.

I'm also interpolating the rigidbody2d, so thats neither the issue.

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

21 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

Related Questions

How do I iterate all animation clips used by an Animator? 2 Answers

Whever I try to change an Animator value in my script, it becomes incredibly laggy [C#] 1 Answer

Precise animation control 4 Answers

"Empty" Animator transition is overriding other trigger based transition 1 Answer

Can't manually rotate bones in inspector or through script. 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