Hello.
The enemies in my game are trying to shoot the Player regardless of whether or not another enemy is in the way. hence, enemy “friendly fire” occurs which is sometimes funny to see and to some extent realistic but I want to avoid it. :?
Hence, i put in a Physics.Linecast statement to check if there is something blocking the player before the enemy fires.
if (!Physics.Linecast (transform.position, objPlayer.transform.position))
{
shootPlayer();
}
Unfortunately, this isn’t working for me because apparently there is something ALWAYS in the way and so the enemy no longer fires at anything. I suspect it could be the actual rigid body of the enemy object but I am not sure how to check for this.
Should I be using layer masks to solve this issue?
If anyone can offer some insight or point me in the right direction, I would really appreciate it.
thank you in advance,