1
0
forked from cgvr/DeltaVR

add character sprites, mouth moving open closed

This commit is contained in:
2025-12-19 11:00:22 +02:00
parent f184151fdb
commit 39b4a24ef3
17 changed files with 852 additions and 4 deletions

View File

@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NPCController : MonoBehaviour
{
private Transform mouthTransform;
private Vector3 mouthClosedScale;
private Vector3 mouthOpenScale;
private bool isTalking;
public float mouthScalingMultiplier = 2.5f;
// Start is called before the first frame update
void Start()
{
mouthTransform = transform.GetChild(0).transform;
mouthClosedScale = mouthTransform.localScale;
mouthOpenScale = new Vector3(mouthClosedScale.x, mouthClosedScale.y * mouthScalingMultiplier, mouthClosedScale.z);
isTalking = false;
}
// Update is called once per frame
void Update()
{
}
public void StartTalking()
{
isTalking = true;
MoveMouth();
}
public void Stoptalking()
{
isTalking = false;
}
private void MoveMouth()
{
if (!isTalking)
{
return;
}
if (mouthTransform.localScale == mouthClosedScale)
{
mouthTransform.localScale = mouthOpenScale;
}
else
{
mouthTransform.localScale = mouthClosedScale;
}
Invoke("MoveMouth", 0.5f);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: baa11cfc03dc213438961722257e2e94
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: