• 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 SuperSparkplug · Oct 27, 2013 at 11:18 PM · mecanim

SetLookAtPosition Shaking Glitch

Right now, I'm trying to test out Unity Pro by accessing some of the Pro-exclusive functions, like anim.SetLookAtPosition.

I'm trying to make my character look at a ball. While it does this sucessfully, the head is constantly shaking and jittering while it's looking at the ball. Anyone know why this is the case?

     void FixedUpdate ()
     {
         float h = Input.GetAxis("Horizontal");                // setup h variable as our horizontal input axis
         float v = Input.GetAxis("Vertical");                // setup v variables as our vertical input axis
         anim.SetFloat("speed", v);                            // set our animator's float parameter 'Speed' equal to the vertical input axis                
         anim.SetFloat("direction", h);                         // set our animator's float parameter 'Direction' equal to the horizontal input axis        
         anim.speed = animSpeed;                                // set the speed of our animator to the public variable 'animSpeed'
         anim.SetLookAtWeight(lookWeight);                    // set the Look At Weight - amount to use look at IK vs using the head's animation
         currentBaseState = anim.GetCurrentAnimatorStateInfo(0);    // set our currentState variable to the current state of the Base Layer (0) of animation
         
         if (lookAtMe == true) {
             anim.SetLookAtPosition(ball.position);
             lookWeight = Mathf.Lerp(lookWeight,1f,Time.deltaTime*lookSmoother);
         }
         else {
             lookWeight = Mathf.Lerp(lookWeight,0f,Time.deltaTime*lookSmoother);
             }
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by SuperSparkplug · Dec 05, 2014 at 09:20 AM

I posted this question over a year ago. I couldn't figure it out then, but I accidentally figured it out just now. Which I will post here for anyone also having this issue.

To stop the shaking make sure Animate Physics is enabled/selected/checked in your character's Animator panel within your Inspector. In newer versions of Unity, you'll find Animate Physics in the Update Mode section of the Animator. This will stop your character's head from shaking/twitching when he looks at things. No idea why it works, but it works!

Hope this helps anyone having a similar problem as me! :)

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
avatar image
0

Answer by TenTickles · Nov 14, 2013 at 06:14 AM

Hey, this might be a bit late but try using SetLookAtPosition under Update instead of FixedUpdate.

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
avatar image
0

Answer by cwinder_hothead · May 05, 2014 at 06:22 PM

Im having the same problem with my calls already under update. It also seems worse on device, possibly due to framerate. I did find another thread where someone suggested SetLookAtPosition and SetLookAtWeight should be called from OnAnimatorIK.

Ive just tried this and it appears to work. I did also have to check the "IK Pass" checkbox in the animator window to get OnAnimatorIK( int layerIndex) to be called but after that it worked.

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

17 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

Related Questions

Mecanim LookAtPosition mobile problem I'm having 0 Answers

Animator.SetLookAtPosition is Inverted? 0 Answers

Mecanim: Changing look at targets. 0 Answers

Head Look for Mecanim 1 Answer

SetLookAtPosition looking in the wrong direction 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