forked from cgvr/DeltaVR
add DoTween and use it for animating mouth scaling
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
|
||||
public class NPCController : MonoBehaviour
|
||||
{
|
||||
private Transform mouthTransform;
|
||||
private Vector3 mouthClosedScale;
|
||||
private Vector3 mouthOpenScale;
|
||||
private bool isTalking;
|
||||
|
||||
public Transform mouthTransform;
|
||||
public float mouthScalingMultiplier = 2.5f;
|
||||
public float mouthMovementDuration = 0.25f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
void Awake()
|
||||
{
|
||||
mouthTransform = transform.GetChild(0).transform;
|
||||
mouthClosedScale = mouthTransform.localScale;
|
||||
mouthOpenScale = new Vector3(mouthClosedScale.x, mouthClosedScale.y * mouthScalingMultiplier, mouthClosedScale.z);
|
||||
|
||||
@@ -48,13 +49,13 @@ public class NPCController : MonoBehaviour
|
||||
|
||||
if (mouthTransform.localScale == mouthClosedScale)
|
||||
{
|
||||
mouthTransform.localScale = mouthOpenScale;
|
||||
mouthTransform.DOScale(mouthOpenScale, mouthMovementDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
mouthTransform.localScale = mouthClosedScale;
|
||||
mouthTransform.DOScale(mouthClosedScale, mouthMovementDuration);
|
||||
}
|
||||
|
||||
Invoke("MoveMouth", 0.5f);
|
||||
Invoke("MoveMouth", mouthMovementDuration + 0.01f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user