public Vector3 getPositionAtFrame(float frame) { if (cache.Count <= 0) { return(obj.position); } // if before first frame if (frame <= (float)cache[0].startFrame) { return((cache[0] as AMTranslationAction).path[0]); } // if beyond last frame if (frame >= (float)(cache[cache.Count - 1] as AMTranslationAction).endFrame) { return((cache[cache.Count - 1] as AMTranslationAction).path[(cache[cache.Count - 1] as AMTranslationAction).path.Length - 1]); } // if lies on curve foreach (AMTranslationAction action in cache) { if (((int)frame < action.startFrame) || ((int)frame > action.endFrame)) { continue; } if (action.path.Length == 1) { return(action.path[0]); } // ease AMTween.EasingFunction ease; AnimationCurve curve = null; if (action.hasCustomEase()) { ease = AMTween.customEase; curve = action.easeCurve; } else { ease = AMTween.GetEasingFunction((AMTween.EaseType)action.easeType); } float framePositionInPath = frame - (float)action.startFrame; if (framePositionInPath < 0f) { framePositionInPath = 0f; } return(AMTween.PointOnPath(action.path, Mathf.Clamp(ease(0f, 1f, framePositionInPath / action.getNumberOfFrames(), curve), 0f, 1f))); } Debug.LogError("Animator: Could not get " + obj.name + " position at frame '" + frame + "'"); return(new Vector3(0f, 0f, 0f)); }