Animation OnCollisionEnter

Im trying to work wit a OnCollisionEnter script for some reason my animation to swing at the object wont work just wanted to know if anything is missing.

using UnityEngine;
using System.Collections;

public class animplay : MonoBehaviour {
	public AnimationClip clip;

	
	//oncollision play animation
	void OnCollisionEnter (Collision col) {
				if (col.gameObject.tag == "Barrier") 
		{

			gameObject.SampleAnimation(clip, clip.length - Time.time);
				}
		}

}

any help please…

Time.time is the time since start of the game… so most likely clip.length - Time.time is zero and it doesn’t play any frames.

Try gameObject.GetComponent().Play(“swing”) and make sure you have an animation called “swing” available.