void SetMouthState(MouthState _state) { if (m_MouthState == MouthState.Spit && m_MouthCD > 0) { return; } foreach (MouthAnimKVP mak in m_MouthElements) { mak.gameObject.SetActive(mak.state == _state); } m_MouthState = _state; switch (m_MouthState) { case MouthState.Open: m_MouthCD = 0.5f; break; case MouthState.Chew: m_MouthCD = 0.5f; break; case MouthState.Spit: m_MouthCD = 0.55f; break; } }
private void SetMouth(MouthState state) { int ci = -1; if (stateMap.TryGetValue((int)state, out ci)) { sRenderer.sprite = configs[ci].sprite; } }
// Use this for initialization void Start() { open = 0f; close = 0f; blow = 0f; smile = 0f; frown = 0f; mouthState = MouthState.neutral; index = 0; //InvokeRepeating ("Express", 2f, 2f); }
void Update() { if (Input.GetMouseButton(0)) { state = MouthState.Open; this.transform.localScale = new Vector3(0.65f, 2, 1); } else { state = MouthState.Closed; this.transform.localScale = new Vector3(0.65f, 1, 1); } }
/* * Mapping of strings to mouth state enum * We want to map strings to enums so we can set the facial expressions * From the inspector too, using the enum, but can use a string to set * The expression from another function */ public void SetMouth(string state) // Use this function to set the mouth expression from other scripts { switch (state) { case "smiling": mouth = MouthState.smiling; break; case "neutral": mouth = MouthState.neutral; break; case "frowning": mouth = MouthState.frowning; break; } }
void SetMouth(MouthState state) // Set the mouth expression using enum, don't use this outside this script { switch (state) { case MouthState.smiling: mouthMat.SetTexture("_MainTex", smilingTexture); break; case MouthState.neutral: mouthMat.SetTexture("_MainTex", neutralTexture); break; case MouthState.frowning: mouthMat.SetTexture("_MainTex", frowningTexture); break; } mouthRend.material = mouthMat; }
private void Update() { if (PlayerManager.instance.target != null) { if (presentTargets.Count > 0) { state = MouthState.Biting; } else if (PlayerManager.instance.target.layer == LayerMask.NameToLayer("Creature")) { state = MouthState.Firebreathing; } else { state = MouthState.Idle; } } else { state = MouthState.Idle; } }
public void SetMouthState(MouthState state) { this.mouth.SetState(state); }
IEnumerator SetExpressionCR(MouthState expression, float seconds) { bool complete = false; float sOpen = open; float sClose = close; float sBlow = blow; float sSmile = smile; float sFrown = frown; float t = 0f; SkinnedMeshRenderer r = GetComponent <SkinnedMeshRenderer> (); while (!complete) { switch (expression) { default: open = Mathf.Lerp(sOpen, 0f, t * seconds); close = Mathf.Lerp(sClose, 0f, t * seconds); blow = Mathf.Lerp(sBlow, 0f, t * seconds); smile = Mathf.Lerp(sSmile, 0f, t * seconds); frown = Mathf.Lerp(sFrown, 0f, t * seconds); if (open + close + blow + smile + frown < float.Epsilon) { complete = true; } break; case MouthState.open: open = Mathf.Lerp(sOpen, 100f, t * seconds); close = Mathf.Lerp(sClose, 0f, t * seconds); blow = Mathf.Lerp(sBlow, 0f, t * seconds); smile = Mathf.Lerp(sSmile, 0f, t * seconds); frown = Mathf.Lerp(sFrown, 0f, t * seconds); if (100f - open < float.Epsilon) { complete = true; } break; case MouthState.close: open = Mathf.Lerp(sOpen, 0f, t * seconds); close = Mathf.Lerp(sClose, 100f, t * seconds); blow = Mathf.Lerp(sBlow, 0f, t * seconds); smile = Mathf.Lerp(sSmile, 0f, t * seconds); frown = Mathf.Lerp(sFrown, 0f, t * seconds); if (100f - close < float.Epsilon) { complete = true; } break; case MouthState.blow: open = Mathf.Lerp(sOpen, 0f, t * seconds); close = Mathf.Lerp(sClose, 0f, t * seconds); blow = Mathf.Lerp(sBlow, 100f, t * seconds); smile = Mathf.Lerp(sSmile, 0f, t * seconds); frown = Mathf.Lerp(sFrown, 0f, t * seconds); if (100f - blow < float.Epsilon) { complete = true; } break; case MouthState.smile: open = Mathf.Lerp(sOpen, 0f, t * seconds); close = Mathf.Lerp(sClose, 0f, t * seconds); blow = Mathf.Lerp(sBlow, 0f, t * seconds); smile = Mathf.Lerp(sSmile, 100f, t * seconds); frown = Mathf.Lerp(sFrown, 0f, t * seconds); if (100f - smile < float.Epsilon) { complete = true; } break; case MouthState.frown: open = Mathf.Lerp(sOpen, 0f, t * seconds); close = Mathf.Lerp(sClose, 0f, t * seconds); blow = Mathf.Lerp(sBlow, 0f, t * seconds); smile = Mathf.Lerp(sSmile, 0f, t * seconds); frown = Mathf.Lerp(sFrown, 100f, t * seconds); if (100f - frown < float.Epsilon) { complete = true; } break; case MouthState.eat: //print("Open: " + open + "\tClose: " + close); if (t > 1f) { open = Mathf.Max(0f, 100 * Mathf.Cos(2 * 2 * Mathf.PI * (t - 1f))); close = Mathf.Max(0f, -100 * Mathf.Cos(2 * 2 * Mathf.PI * (t - 1f))); blow = Mathf.Lerp(sBlow, 0f, t * seconds); smile = Mathf.Lerp(sSmile, 0f, t * seconds); frown = Mathf.Lerp(sFrown, 0f, t * seconds); } if (t > 2.75f) { complete = true; } break; } r.SetBlendShapeWeight(0, open); r.SetBlendShapeWeight(1, close); r.SetBlendShapeWeight(2, blow); r.SetBlendShapeWeight(3, smile); r.SetBlendShapeWeight(4, frown); t += Time.deltaTime; yield return(new WaitForEndOfFrame()); } }
public void SetExpression(MouthState expression, float seconds = 1f) { StopCoroutine("SetExpressionCR"); StartCoroutine(SetExpressionCR(expression, seconds)); }
public void SetState(MouthState newState) { this.state = newState; }
// Update is called once per frame void FixedUpdate() { // Eating code MouthState newMouthOpen = MouthState.Neutral; float jawAxis = Input.GetAxis("JawAxis"); if (jawAxis > 0) { newMouthOpen = MouthState.Open; } else if (jawAxis < 0) { newMouthOpen = MouthState.Closed; } if ((currentMouthOpen == MouthState.Open) && (newMouthOpen == MouthState.Closed)) { //currentMouthOpen = MouthState.Closed; performedEat = true; // this will possibly change to on player action } if ((newMouthOpen == MouthState.Closed) || (newMouthOpen == MouthState.Open)) { currentMouthOpen = newMouthOpen; // Store new non-neutral state of jaw } if (performedEat) { EatSwimmer(); performedEat = false; } }
void Start() { currentMouthOpen = MouthState.Neutral; performedEat = false; }