Well,you are not showing any code where you are moving the player, or telling the nav agent where to move to. That makes it very difficult to determine where the problem is.
The Mistake is there thasts for sure because I know the Error but don know how to solve it in a different way.
The Problem is that the Linecast collides with the player for like 8 sec and that should not happen. After the 8 sec it isn’t colliding anymore. But WHY is that ? Thats the main question.
Well, we don’t know if what you think is the error really is the error, or what you believe the error to be. How can we help if we don’t know what’s wrong? The code you showed so far seems fine: it looks if the player is within the FOV or within 2m of the enemy, and then sets some variables accordingly. It doesn’t reset PersonalLastSight, but I don’t know if that is a factor because you don’t show any code where that is being used.
Oh, wait - your issue isn’t that the enemy collides with the player for the first 8 seconds, but that your LineCast in SeesPlayer() detects a collision. You then assume the collision detcted is the player. How do you know it’s the player and not some other object?
To make sure that LineCast is really being triggered by the correct colliders, replace LineCast with RayCastAll, and Log out all colliders objects that are hit with the cast.
int layerMask = ~ignoreLayers;
Ray targetRay = new Ray(gameObject.transform.position, (enemyPosition - playerPosition));
RaycastHit[] rHits = Physics.RaycastAll(targetRay, 100f, layerMask);
foreach (RaycastHit hit in rHits)
{
Debug.log("Hit collider of " + hit.collider.gameObject.name);
}
check which objects are hit, and if they really hit the player, not something else. Note that (enemyPosition - playerPosition) is the direction to the player, you may need to turn the vector around (by adding a ‘-’ sign in front).
-ch