triggering animated objects to start 'playing' when you get closer to them in game

How can I go about setting this up?

I know how to turn a light on and off depending on how close or far I get to it. I want to modify this so it instead it plays an animation I keyframed within Unity.

use OnTriggerEnter() and animation.Play() or animation.Stop().