Skip to content

Instantly share code, notes, and snippets.

Last active February 12, 2017 13:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
/*copied from complete version in sample project of ""*/
private void ExpandModelCommand(PhraseRecognizedEventArgs args)
// Swap out the current model for the expanded model.
GameObject currentModel = ExpandModel.Instance.gameObject;
ExpandModel.Instance.ExpandedModel.transform.position = currentModel.transform.position;
ExpandModel.Instance.ExpandedModel.transform.rotation = currentModel.transform.rotation;
ExpandModel.Instance.ExpandedModel.transform.localScale = currentModel.transform.localScale;
// Play animation. Ensure the Loop Time check box is disabled in the inspector for this animation to play it once.
Animator[] expandedAnimators = ExpandModel.Instance.ExpandedModel.GetComponentsInChildren<Animator>();
// Set local variables for disabling the animation.
if (expandedAnimators.Length > 0)
expandAnimationCompletionTime = Time.realtimeSinceStartup + expandedAnimators[0].runtimeAnimatorController.animationClips[0].length * 0.9f;
// Set the expand model flag.
isModelExpanding = true;
public void Update()
if (isModelExpanding && Time.realtimeSinceStartup >= expandAnimationCompletionTime)
isModelExpanding = false;
Animator[] expandedAnimators = ExpandModel.Instance.ExpandedModel.GetComponentsInChildren<Animator>();
foreach (Animator animator in expandedAnimators)
animator.enabled = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment