Control an animation with a slider

Does anyone know how to do this? I tried to use animation.sample but didn’t quite work.

Well as I’m off for a bit - I will assume you meant how do I control the current position of an animation using a slider:

   var sliderPos : float = 0;
   var animationName = "nameOfAnimation";

   function Start() {
         animation[animationName].enabled = true;
         animation[animationName].weight = 1;

   function OnGUI() {

        sliderPos = GUI.HorizontalSlider(Rect(40,40,400,20), sliderPos, 0.0, 1.0);
        animation[animationName].normalizedTime = sliderPos;


here is a simple code for c#.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class AnimControl : MonoBehaviour {
	Animation anim;
	public Slider slider;

	// Use this for initialization
	void Start () {
		anim = GetComponent<Animation> ();
		anim.Play ("SphereAnim");
		anim ["SphereAnim"].speed = 0;
	// Update is called once per frame
	void Update () {
		anim["SphereAnim"].normalizedTime= slider.value;

Sounds like iTween could be the answer: iTween for Unity by Bob Berkebile (pixelplacement) scroll down to “Using PutOnPath and PointOnPath”, there’s plenty of documentation on how to implement it on the itween website itself.

This is working for me pretty darn well. I am currently working on getting this to work with a play/pause button as well. Let me know if you want to see what I have for that so far.

private var hSliderValue : float = 0.0;
private var myAnimation : AnimationState; 

function Start(){
    myAnimation = animation["Take 001"];
function LateUpdate() {     
	myAnimation.time = hSliderValue;
	myAnimation.enabled = true;
	myAnimation.enabled = false;  
function OnGUI() {
	// Horizontal slider
	GUILayout.BeginArea (Rect (60,Screen.height - 30,1220,60));
    hSliderValue = GUILayout.HorizontalSlider (hSliderValue, 0.0, myAnimation.length, GUILayout.Width(1200.0f));
    GUILayout.EndArea ();

For me work perfect. How can i the size of the touch slider buttom bigger?