Cannot rotate GameObject from C# Animator attached

I have tried almost every api call that lets you rotate a gameobject, and this thing will NOT rotate via code, using C#.

  • It has an animator attached that animates rotation, but the rotation animation is not playing when I try to rotate from code (only a position animation is playing).

  • The gameobject & parents are not static.

  • Have tried rotation gameobject and parent, neither one will rotate.

  • Have tried euler angles rotations, quaternion rotations, transform.lookat, no errors but the thing will never rotate from it’s original position while playing the position animation (up-down motion animating Y value of position.

I even recorded a youtube video to help explain the problem:
[- YouTube][1]
[1]: - YouTube

Why can’t I rotate this gameobject from code? Any help much appreciated!!

“If its the animator interfering, putting rotation code into LateUpdate should fix your problem.”

http://forum.unity3d.com/threads/cannot-rotate-gameobject-from-c-with-animator-attached.313765/#post-2038896

Thanks to James at the Unity Forums. I still have a question though, see I’m not doing anything on each frame only calling “transform.lookAt” one time, so update or LateUpdate not the best because I have to check if I should run that line of code every frame. For example (this works finally though!):

void LateUpdate(){ if (shouldLookAtPlayer == true) { transform.LookAt(transform.position); } }

So now I have to set a bool, and then every frame it has to check if that’s true or false, then run my line of code. Is there a way to run function “late” without LateUpdate?

For example, something like:

void MyFunctionThatRunsLate(){ transform.LookAt(transform.position); }

And then I can just call that without running a bool check every frame?