How to deal with player detection

I’m developing NPC speech for my game, it is entirely finished but for one detail, I can’t digure out how to only make my speech work when the player is close to the NPC he will talk to. My player is a CharacterController and my NPC is currently a box collider, but this could be changed to whatever is necessary. I’ve tried to use OnCollisionEnter but I don’t think that works with CharacterControllers. I’ve considered instead having the speech only function when an object with the tag “Player” is within a certain distance of my NPC, that could be an option. I’ve also thought about ray casting, but that doesn’t really give the desired effect. Thanks for any suggestions, any help is appreciated. (I’m writing in C#)

Good day.

You sould use OnTriggerEnter() (CharacyerControler or a Rigidbody is needed for this function) or as you said, by calculating the Vector3.Distance (player, object). The OnTriggerEnter is the best option i think, as it only will execute once when approaching. Is used like OnCollisionEnter, but with trigger colliders.

Bye!