Animation on Collision Problem

i have a script and i want it so when the object collides with my player it will play the animation attack until it uncollides when it is uncollided i want it to play no animation here’s what i have. `var Animation : String;

function OnCollisionEnter (myCollision : Collision) {

    if(myCollision.gameObject.name == "Blood Trails Player"){
	    animation.CrossFade("attack");   
    }

}`

it should be like this assuming the animation is attached to the same object as the script.

if(myCollision.gameObject.name == "Blood Trails Player"){
        animation.Play("attack");   
    }

if the animation is in another object they you will have to do something like this

var player : Transform;

if(myCollision.gameObject.name == "Blood Trails Player"){
        player.animation.CrossFade("attack");   
    }

setting the player var to the object containing the animation