I have a cover system set up that works for the most part; however, I want units able to shoot other units that are at wall corners. Right now, the raycast can be stopped by the obstacle giving full cover, which makes it impossible to target that unit.
I tried altering the code in ShootAction.cs
by including a check shown below
if (Physics.Raycast(
unitWorldPosition + Vector3.up * unitShoulderHeight,
shootDir,
Vector3.Distance(unitWorldPosition, targetUnit.GetWorldPosition()),
obstaclesLayerMask))
{
if (targetUnit.GetCoverType() == CoverType.None || targetUnit.GetCoverType() == CoverType.Half)
{
//Blocked by obstacle and no full cover
continue;
}
}
However, this has the problem of letting units shoot through walls if the target has full cover. Is there a way to stop a ray once it touches an obstacle before it gets to the target unit? Or is there some other way of allowing a unit to shoot at a target with full cover only if there are no other obstacles between them?