- Home /
Lerping blinks
Hi, I have a problem thats been bugging me for a while. Im trying to build some natural facial animation scripts and having trouble with timing. Currently, in this script, I have the character blinking using loops, where I can control the speed, but its very robotic. I would like to be able to lerp the motion to ease in/out the anim but if I try inserting blinkLerp it doesnt finish the motion due to yield not working the way I want or it jumps to open of closed.
As a whole, Id love to find a better way to do this, Lerping at random intervals, but have had little success in achieving it. Any help would be appreciated. Thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class blendCTRL : MonoBehaviour
{
int blinkDown = 10;
int counter = 100;
bool blinker=false;
int blendSpeed = 50;
public int lidHeightMax = 10;
private SkinnedMeshRenderer skinMeshRenderer;
void Start()
{
StartCoroutine(RandomWait());
skinMeshRenderer = GetComponent<SkinnedMeshRenderer>();
}
IEnumerator RandomWait()
{
while (true)
{
yield return new WaitForSeconds(Random.Range(0, 5));
blinker = true;
}
}
void Update()
{
skinMeshRenderer.SetBlendShapeWeight(0, blinkDown);
if (blinker == true & blinkDown < counter)
{
blinkDown = blinkDown + 10;
}
else if (blinkDown == 100)
{
while (blinkDown > lidHeightMax)
{
blinkDown--;
}
blinker = false;
}
}
void blinkLerp()
{
skinMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(0, 100, blendSpeed * Time.deltaTime));
}
}
Answer by D-Coy · Sep 11, 2017 at 08:49 PM
Still looking for help on this. Triggering a ping ponging, lerped blend at random intervals. thanks