
It looks like you're new here. If you want to get involved, click one of these buttons!
How to check if the player is too near the enemy?
Use
Physics.SphereCast;
see the second one.
Make sure that enemy gameobject's layer is set to Enemy.
Attach this script to Your Player
make a new script, EnemyCheck, or add this code to PlayerController(if you have one)
public void DetectEnemy() { RaycastHit[] colliders = Physics.SphereCast(transform.position, 5f, enemyMask); //each one in colliders is your enemy }
More Info (if you cannot understand mine)