1
0
forked from cgvr/DeltaVR

mouth animation correctly plays even if previous voiceline is interrupted

This commit is contained in:
2026-03-16 15:40:31 +02:00
parent 6a77893ed7
commit cad4c2cbbc
3 changed files with 5 additions and 40 deletions

View File

@@ -5,7 +5,6 @@
* uurida miks buildis Whisper halvemini töötab
* proovida suuremat Whisperi mudelit, äkki töötab mürases keskkonnas paremini
* npc character:
* suu animatsioon jääb seisma, kui uus voiceline algab kui eelmine veel mängib
* klaas on näha temast eespool
* shape detection:
* peab mängijale kuidagi selgitama, kuidas scale'ida prinditud objekte

View File

@@ -26,25 +26,13 @@ public abstract class NPCController : MonoBehaviour
private float[] rmsCurve;
private EventInstance currentVoicelineEvent;
private bool isSpeaking;
private float smoothed;
// If you change RMS window in Python, update this
private const float FRAME_DURATION = 0.02f;
private float sampleRate = 1f / FRAME_DURATION; // RMS samples per second (20ms windows)
private readonly float sampleRate = 1f / FRAME_DURATION; // RMS samples per second (20ms windows)
// Start is called before the first frame update
void Awake()
{
}
void Start()
{
}
// Update is called once per frame
void Update()
{
@@ -65,7 +53,7 @@ public abstract class NPCController : MonoBehaviour
}
}
if (isSpeaking && rmsCurve != null && currentVoicelineEvent.isValid())
if (rmsCurve != null && currentVoicelineEvent.isValid())
{
AnimateMouth();
}
@@ -105,22 +93,6 @@ public abstract class NPCController : MonoBehaviour
mouth.localScale = s;
}
private void StopSpeaking()
{
isSpeaking = false;
smoothed = inverted ? maxScaleY : minScaleY;
if (mouth != null)
{
var scale = mouth.localScale;
scale.y = smoothed;
mouth.localScale = scale;
}
currentVoicelineEvent.release();
}
public void PlayerApproach() {
OnPlayerApproach();
@@ -168,21 +140,15 @@ public abstract class NPCController : MonoBehaviour
LoadCurve(key); // load RMS data
emitter = emitter ?? gameObject;
emitter = emitter != null ? emitter : gameObject;
currentVoicelineEvent = AudioManager.Instance.PlayDialogue(characterSpecificFolder + "/" + key, emitter, radioAmount);
if (!currentVoicelineEvent.isValid())
{
Debug.LogError("Failed to start dialogue event.");
return;
}
isSpeaking = true;
// Stop mouth on end
float voicelineDuration = rmsCurve.Length * FRAME_DURATION;
Invoke(nameof(StopSpeaking), voicelineDuration + 0.1f);
}
// ---------------------------
// Load RMS Timeline (.txt)
// ---------------------------