1
0
forked from cgvr/DeltaVR

add DoTween and use it for animating mouth scaling

This commit is contained in:
2025-12-19 11:36:37 +02:00
parent 39b4a24ef3
commit 8b037369b7
46 changed files with 6342 additions and 10 deletions

View File

@@ -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);
}
}