I tried to call the function below to flip my character game object, and it works just fine, but only if the animator component is disabled. For some reason if the animations run the transform will not change. I've been looking for hours for other solutions but nothing has worked.

void Flip()
    {
        facingRight = !facingRight;
        Vector3 Scaler = transform.localScale;
        Scaler.x *= -1;
        transform.localScale = Scaler;
    }

Even if I manually change the transform rotation x while the animator is enabled, the character still won't flip.

I've tried moving my code to different locations (update, fixed update, late update, etc.,) as well as the code for the animation transitions, but that changed nothing. I've also tried other similar scripts I saw recommended, but so far nothing's worked. I feel like maybe I'm just missing something obvious since I'm a complete beginner, but I just can't figure out what.

1

There are 1 best solutions below

2
Raheel Zahid On

It is called property locking. any property referenced in animator is controlled by animator. simply override that property after animator has updated the properties of transform. In LateUpdate();