public void UpdateOrientation(int nextDir, bool forceUpdate = false) { if (nextDir != direction && nextDir != 0 && !canFlipDir) { canFlipDir = true; lastPlace = rbody.transform.position; } // We need to flip the sprite if (forceUpdate || (canFlipDir && Vector3.SqrMagnitude(lastPlace - rbody.transform.position) > maxDistBeforeFlip * maxDistBeforeFlip)) { direction *= -1; canFlipDir = false; head.Flip(); hat.Flip(direction); // Flip tired puff Transform puffTrans = tiredAnimation.transform; Vector3 eulerAngles = puffTrans.localEulerAngles; eulerAngles.z *= -1; puffTrans.localRotation = Quaternion.Euler(eulerAngles); Vector3 pos = puffTrans.localPosition; pos.x *= -1; Vector3 scale = puffTrans.localScale; scale.x *= -1; puffTrans.localScale = scale; puffTrans.localPosition = pos; } }