Skip to main content

VoiceChatMouthController

A class in Root.Township, Alta.Networking.Voice.

Animates a player's mouth from their voice chat volume: sets the Speaking layer weight and picks random mouth shapes. Client only; turns itself on once linked to a player, never when headless.

Constructors​

MemberWhat it is
VoiceChatMouthController()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

11 private and internal fields
MemberWhat it is
private Animator animatorThe character dummy's animator.
private PlayerController controllerThe player controller this belongs to.
private CharacterDummyPointer dummyPointer to the character dummy that holds the animator.
private float lastChangeVolumeVolume level at the last mouth shape change.
private float mouthChangeChanceBase chance per frame of a new mouth shape (default 0.2).
private static readonly int MouthShapeIDAnimator hash for the Mouth Shape parameter.
private float normalizedVolumeShiftChangeExtra chance per unit of volume change since the last shape change.
private int numberOfMouthShapesHow many mouth shapes to pick from.
private Player playerThe network player whose voice is read.
private int speakingLayerIndex of the animator's Speaking layer.
private AnimationCurve voiceModulatorCurve that turns voice energy into layer weight.

Methods​

3 private and internal methods
MemberWhat it is
private void Awake()Finds the player controller, waits for it to link to a player, and disables itself until then.
private void Initialize()Gets the character animator and player, finds the Speaking layer and enables the component.
private void LateUpdate()Sets the Speaking layer weight from voice energy and sometimes picks a new mouth shape.