So I have an AI code that works fine and everything, in order for the AI to detect the player there is a timer for how long it must see the player and a distance limit on how close they must be. To “see” the player I have a linecast in place and if the linecast retuns false then the timer starts and it checks the distance of the hit point. However, when the player is just slightly peaking out of cover and the collider is barely visible, along with the other detection conditions being met, it will spot them. What I am trying to do is make it so that more of the player has to be visible to detect them, without messing with the colliders. What I have thought of doing is making the linecast move around close to the hit point for some time and if the collider is still visible then it will have detected the player, but is there a more practical way of doing this? If not how can I go about implementing what I stated above?
You could come with a script that detects how much the player is leaning out and if it’s under a certain amount you can place a collider in front of the player so the linecast hits that instead. Normally I’d do something that says they can only detect the player if he’s not behind something, but I’m assuming you’ll have enemies coming from the back as well, meaning you should just block the linecast. Or you could have the “detect point” move according to where the player is behind an object. So you could move the player’s collider according to how much he is behind cover.
You can use spherecast