anchoredPosition in mechanim locks my axis

Hello,

I have a UI Text object. I affect it in several ways:

  1. I move it down with mechanim affecting its pivot

  2. I scale is up and down several times using mechanim affecting it’s scale

  3. I shake it (move it inside unitSphere on y/x axis) with the below script

    void Update () 
    {
    	ShakeStandBy ();
    }
    
    void ShakeStandBy()
    {
    	if(shakeIntensity > 0)
    	{
    		transform.position = originalPosition + Random.insideUnitSphere * shakeIntensity;
    		shakeIntensity -= shakeDecay;
    	}
    	else
    	{
    		transform.position = originalPosition;
    	}
    }
    

1.”, “2.” and “3.” all work fine on their own.

Here’s the problem:
In “2.” I also need to affect the anchoredPosition because by that time the text is moved with “1.” and its pivot is modified, so to counter that I also affect anchoredPosition in my scaling animation which gives the desired effect - the text is scaled from its CENTER and remains in the desired location. If I were to counter this effect by affecting pivot instead, the scaling would not happen from the center but from the top (since I moved the Text DOWN).

As soon as I use anchoredPosition in my animation, the shake stops working on the y axis as if it’s locked and only works on x axis. I don’t even have to run that animation, it’s sufficient to have a state in the animator with this animation (that affects anchoredPosition somehow) plugged in, and the shake won’t work. If you unplug it, it’s works normally again.

I tried rewriting the shake function with GetComponent().anchoredPosition but I get the same result.
I spent the entire day trying various workarounds and nothing solves this issue.

Does anyone know why do I get such behaviour?

Thanks in advance.

Yup, mecanim just works this way, move your ShakeStadBy() call to LateUpdate instead of regular Update. I fixed my animation problems this way.
And this maybe interesting: http://docs.unity3d.com/Manual/ExecutionOrder.html
This is for 2) and 3).

For 1) and 2) you can also try using animation layers and play with override value.