// Called by unity each frame after Update/Animations void LateUpdate() { // Move eyes towards mouse pointer. eyeX.BlendToValue(CubismParameterBlendMode.Override, pt.position.x * eyeXSpeed); eyeY.BlendToValue(CubismParameterBlendMode.Override, pt.position.y * eyeYSpeed); // Check if wobble is still going on. if (wobbleMagnitude > 0.01f) { // If so, slowly open closed eyes and set X/Y wobble position. paramX.BlendToValue(CubismParameterBlendMode.Override, -wobbleAmount * wobbleDir.x * (wobbleFinal + 1) / 2.0f); paramY.BlendToValue(CubismParameterBlendMode.Override, -wobbleAmount * wobbleDir.y * (wobbleFinal + 1) / 2.0f); eyeOpenL.BlendToValue(CubismParameterBlendMode.Override, 1 - wobbleMagnitude - 0.5f); eyeOpenR.BlendToValue(CubismParameterBlendMode.Override, 1 - wobbleMagnitude - 0.5f); } else { if (fadeBack > 0.01) { // Otherwise slowly fade back to the values given by the animation. float x = Mathf.Lerp(paramX.Value, -wobbleAmount * wobbleDir.x * (wobbleFinal + 1) / 2.0f, fadeBack); float y = Mathf.Lerp(paramY.Value, -wobbleAmount * wobbleDir.y * (wobbleFinal + 1) / 2.0f, fadeBack); float eyeL = Mathf.Lerp(eyeOpenL.Value, 0.5f, fadeBack); float eyeR = Mathf.Lerp(eyeOpenR.Value, 0.5f, fadeBack); paramX.BlendToValue(CubismParameterBlendMode.Override, x); paramY.BlendToValue(CubismParameterBlendMode.Override, y); eyeOpenL.BlendToValue(CubismParameterBlendMode.Override, eyeL); eyeOpenR.BlendToValue(CubismParameterBlendMode.Override, eyeR); fadeBack -= 0.05f; } else { fadeBack = 0; } } }
// Called by unity each frame after Update/Animations void LateUpdate() { // Move eyes towards mouse pointer. eyeX.BlendToValue(CubismParameterBlendMode.Override, pt.position.x * eyeXSpeed); eyeY.BlendToValue(CubismParameterBlendMode.Override, pt.position.y * eyeYSpeed); // Check if wobble is still going on. if (wobbleMagnitude > 0.01f) { // If so, slowly open closed eyes and set X/Y wobble position. paramX.BlendToValue(CubismParameterBlendMode.Override, -wobbleAmount * wobbleDir.x * (wobbleFinal + 1) / 2.0f); paramY.BlendToValue(CubismParameterBlendMode.Override, -wobbleAmount * wobbleDir.y * (wobbleFinal + 1) / 2.0f); eyeOpenL.BlendToValue(CubismParameterBlendMode.Override, 1 - wobbleMagnitude - 0.5f); eyeOpenR.BlendToValue(CubismParameterBlendMode.Override, 1 - wobbleMagnitude - 0.5f); } else { if (fadeBack > 0.01) { // Otherwise slowly fade back to the values given by the animation. float x = Mathf.Lerp(paramX.Value, -wobbleAmount * wobbleDir.x * (wobbleFinal + 1) / 2.0f, fadeBack); float y = Mathf.Lerp(paramY.Value, -wobbleAmount * wobbleDir.y * (wobbleFinal + 1) / 2.0f, fadeBack); float eyeL = Mathf.Lerp(eyeOpenL.Value, 0.5f, fadeBack); float eyeR = Mathf.Lerp(eyeOpenR.Value, 0.5f, fadeBack); paramX.BlendToValue(CubismParameterBlendMode.Override, x); paramY.BlendToValue(CubismParameterBlendMode.Override, y); eyeOpenL.BlendToValue(CubismParameterBlendMode.Override, eyeL); eyeOpenR.BlendToValue(CubismParameterBlendMode.Override, eyeR); fadeBack -= 0.05f; } else { fadeBack = 0; } } // Time "Nnaaa" and "angry sign" animation. if (annoyed) { if (angryAmount <= 1) { angryAmount += 0.073f; } if (!prevAnnoyed) { nnaaaAmount = 0f; } nnaaaAmount += 0.0073f; } else { if (angryAmount >= 0) { angryAmount -= 0.025f; } nnaaaAmount += 0.007f; } if (angryAmount <= 0) { nnaaaAmount = 0; } prevAnnoyed = annoyed; // Check if dizzy animation should be played. if (transpHandler.getDizzy()) { if (spinEyeAmount <= 1) { spinEyeAmount += 0.07f; } } else { if (spinEyeAmount >= 0) { spinEyeAmount -= 0.025f; } } // Set new parameter values. eyeSpin.BlendToValue(CubismParameterBlendMode.Override, spinEyeAmount); angry.BlendToValue(CubismParameterBlendMode.Override, angryAmount); nnaa.BlendToValue(CubismParameterBlendMode.Override, nnaaaAmount); if (wobbleMagnitude > 0.01f) { float tempWobble = wobbleMagnitude * wobbleDir.x * (-1.71f); tempWobble = Mathf.Clamp(tempWobble, -1, 1); moveX.BlendToValue(CubismParameterBlendMode.Override, tempWobble); } else { float xSpeed = transpHandler.getXSpeed() / 27f; xSpeed = Mathf.Clamp(xSpeed, -1, 1); moveX.BlendToValue(CubismParameterBlendMode.Override, -xSpeed); } }