forked from cgvr/DeltaVR
mouth animation correctly plays even if previous voiceline is interrupted
This commit is contained in:
@@ -5,7 +5,6 @@
|
|||||||
* uurida miks buildis Whisper halvemini töötab
|
* uurida miks buildis Whisper halvemini töötab
|
||||||
* proovida suuremat Whisperi mudelit, äkki töötab mürases keskkonnas paremini
|
* proovida suuremat Whisperi mudelit, äkki töötab mürases keskkonnas paremini
|
||||||
* npc character:
|
* npc character:
|
||||||
* suu animatsioon jääb seisma, kui uus voiceline algab kui eelmine veel mängib
|
|
||||||
* klaas on näha temast eespool
|
* klaas on näha temast eespool
|
||||||
* shape detection:
|
* shape detection:
|
||||||
* peab mängijale kuidagi selgitama, kuidas scale'ida prinditud objekte
|
* peab mängijale kuidagi selgitama, kuidas scale'ida prinditud objekte
|
||||||
|
|||||||
Binary file not shown.
@@ -26,25 +26,13 @@ public abstract class NPCController : MonoBehaviour
|
|||||||
|
|
||||||
private float[] rmsCurve;
|
private float[] rmsCurve;
|
||||||
private EventInstance currentVoicelineEvent;
|
private EventInstance currentVoicelineEvent;
|
||||||
private bool isSpeaking;
|
|
||||||
private float smoothed;
|
private float smoothed;
|
||||||
|
|
||||||
// If you change RMS window in Python, update this
|
// If you change RMS window in Python, update this
|
||||||
private const float FRAME_DURATION = 0.02f;
|
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
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
@@ -65,7 +53,7 @@ public abstract class NPCController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSpeaking && rmsCurve != null && currentVoicelineEvent.isValid())
|
if (rmsCurve != null && currentVoicelineEvent.isValid())
|
||||||
{
|
{
|
||||||
AnimateMouth();
|
AnimateMouth();
|
||||||
}
|
}
|
||||||
@@ -105,22 +93,6 @@ public abstract class NPCController : MonoBehaviour
|
|||||||
mouth.localScale = s;
|
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() {
|
public void PlayerApproach() {
|
||||||
|
|
||||||
OnPlayerApproach();
|
OnPlayerApproach();
|
||||||
@@ -168,21 +140,15 @@ public abstract class NPCController : MonoBehaviour
|
|||||||
|
|
||||||
LoadCurve(key); // load RMS data
|
LoadCurve(key); // load RMS data
|
||||||
|
|
||||||
emitter = emitter ?? gameObject;
|
emitter = emitter != null ? emitter : gameObject;
|
||||||
currentVoicelineEvent = AudioManager.Instance.PlayDialogue(characterSpecificFolder + "/" + key, emitter, radioAmount);
|
currentVoicelineEvent = AudioManager.Instance.PlayDialogue(characterSpecificFolder + "/" + key, emitter, radioAmount);
|
||||||
if (!currentVoicelineEvent.isValid())
|
if (!currentVoicelineEvent.isValid())
|
||||||
{
|
{
|
||||||
Debug.LogError("Failed to start dialogue event.");
|
Debug.LogError("Failed to start dialogue event.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isSpeaking = true;
|
|
||||||
|
|
||||||
// Stop mouth on end
|
|
||||||
float voicelineDuration = rmsCurve.Length * FRAME_DURATION;
|
|
||||||
Invoke(nameof(StopSpeaking), voicelineDuration + 0.1f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
// Load RMS Timeline (.txt)
|
// Load RMS Timeline (.txt)
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user