Check out this video
It has a method that utilizes the fact that an animal will not move unless a certain number of blocks close to the player. It works on a basis where a cow is surrounded by pressure plates, and when someone gets within the limit, the cow moves, triggering whatever your contraption is.