private void Awake() { if (animations == null) { enabled = false; Debug.LogWarning("No animations added!"); return; } curAnimation = animations[0]; meshRenderers = GetComponentsInChildren <MeshRenderer>(true); }
// This is playing the animation. private void PlayAnimation() { animationTime += Time.deltaTime * curAnimation.Data.frameTime; if (animationTime > curAnimation.Data.duration) { animationTime = 0; int newAnimation = Random.Range(0, animations.Length); curAnimation = animations[newAnimation]; } }
private bool TryGetAnimationWithName(string name, out VA_Animation animation) { foreach (var a in animations) { if (a != null) { if (a.name == name) { animation = a; return(true); } } } animation = null; return(false); }
// This is resembles the VA_AnimatorSystem. private static InterpolationData GetInterpolationData(VA_Animation animation, float animationTime) { InterpolationData data = new InterpolationData(); // Calculate next frame time for lerp. float animationTimeNext = animationTime + (1.0f / animation.Data.maxFrames); if (animationTimeNext > animation.Data.duration) { // Set time. Using the difference to smooth out animations when looping. animationTimeNext -= animationTime; } data.animationTime = animationTimeNext; data.animationMapIndex = animation.Data.animationMapIndex; return(data); }