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);
			}

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

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.

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! :slight_smile: