object distance

I want when the player reach an object (the distance between them may be 20 ) print "something" and then after key "e" pressed play animation

I know how to do it with key press , but I want that, the animation only plays when the distance between the player and the object is 20

You can use

    if ( ( Vector3.Distance(thePlayer.transform.position, theObject.transform.position) <= 20.0f ) && Input.GetKeyDown("E") )
    {
        PlayAnimation();
    }

http://unity3d.com/support/documentation/ScriptReference/Vector3.Distance.html