using UnityEngine;
using System.Collections;
public class AnimManager : MonoBehaviour
{
public GameObject che;
public float currentTime = 0.0f;
public float maxTime = 0.0f;
public AnimationState ani;
void Start()
{
ani = che.animation["Anim01"];
maxTime = ani.length;
}
// Update is called once per frame
void Update()
{
Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (hit.collider.tag == "qianjd")
{
if (Input.GetMouseButton(0))
{
che.animation.Play("Anim01");
if (currentTime >= maxTime)
{
currentTime = maxTime;
}
else
{
currentTime += 0.01f;
}
Debug.Log(currentTime);
}
}
}
}
}
}
void LateUpdate()
{
ani.time = currentTime;
ani.enabled = true;
// Sample animations now.
che.animation.Sample();
ani.enabled = false;
}
}