implementation of drecon in unity 2022 lts
forked from:
https://github.com/joanllobera/marathon-envs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.6 KiB
46 lines
1.6 KiB
8 months ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class ModifyBlendShape : MonoBehaviour
|
||
|
{
|
||
|
private SkinnedMeshRenderer m_SkinnedMeshRenderer;
|
||
|
|
||
|
|
||
|
private void Awake(){
|
||
|
m_SkinnedMeshRenderer = this.GetComponent<SkinnedMeshRenderer>();
|
||
|
StartCoroutine(BlendShapeRoutineEyes());
|
||
|
//StartCoroutine(BlendShapeRoutineMouth());
|
||
|
}
|
||
|
|
||
|
private IEnumerator BlendShapeRoutineEyes(){
|
||
|
yield return new WaitForSecondsRealtime(Random.Range(5f, 10f));
|
||
|
// Blink!
|
||
|
m_SkinnedMeshRenderer.SetBlendShapeWeight(0, Mathf.SmoothStep(0, 100, 1));
|
||
|
m_SkinnedMeshRenderer.SetBlendShapeWeight(1, Mathf.SmoothStep(0, 100, 1));
|
||
|
yield return new WaitForSecondsRealtime(Random.Range(0.25f, 0.75f));
|
||
|
m_SkinnedMeshRenderer.SetBlendShapeWeight(0, Mathf.SmoothStep(0, 100, 0));
|
||
|
m_SkinnedMeshRenderer.SetBlendShapeWeight(1, Mathf.SmoothStep(0, 100, 0));
|
||
|
StartCoroutine(BlendShapeRoutineEyes());
|
||
|
}
|
||
|
|
||
|
private void Update(){
|
||
|
BlendNoise();
|
||
|
}
|
||
|
|
||
|
private void BlendNoise(){
|
||
|
float noise = Mathf.PerlinNoise(Time.time * 0.1f, Time.time * 0.1f);
|
||
|
// m_SkinnedMeshRenderer.SetBlendShapeWeight(0, Mathf.SmoothStep(0, 100, noise));
|
||
|
// m_SkinnedMeshRenderer.SetBlendShapeWeight(1, Mathf.SmoothStep(0, 100, noise));
|
||
|
m_SkinnedMeshRenderer.SetBlendShapeWeight(2, Mathf.SmoothStep(0, 75, noise));
|
||
|
m_SkinnedMeshRenderer.SetBlendShapeWeight(3, Mathf.SmoothStep(0, 75, noise));
|
||
|
}
|
||
|
|
||
|
|
||
|
private IEnumerator BlendShapeRoutineMouth(){
|
||
|
yield return new WaitForSeconds(1);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|