using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// This is a crudely made script just to get this animation in before the comp ends.
// There is a correct way to do this, I just can't recall.
// - Management


public class BlendKeyAnimator : MonoBehaviour {

	[SerializeField]SkinnedMeshRenderer _skinnedMeshRenderer;
	float _animationSpeed = .25f;
	float _animationTime = 0;
	bool _forwardAnimation = true; 

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		this._animationTime += this._forwardAnimation ? Time.deltaTime : -Time.deltaTime;

		if (this._animationTime < 0)
		{
			this._animationTime = 0;
			this._forwardAnimation = true;
		}
		else if (this._animationTime >this._animationSpeed)
		{
			this._animationTime = this._animationSpeed;
			this._forwardAnimation = false;
		}

		
		this._skinnedMeshRenderer.SetBlendShapeWeight(0, (Mathf.Lerp(0, 100, this._animationTime/this._animationSpeed)));
	}
}
