hello, triggering thing when objects are certain distance from each other

I have several moving objects and I wont to trigger material change and animations and material changes if they are close, how can I do it? thank you!

You can use the void OnTriggerEnter() function or use raycasts