Expansion suggestions: Line of Sight System

A proper line of sight system with sight blockers (walls for example) and sight range. Only show enemies within Line of Sight. Fog of War to hide enemies in explored area that are outside of your current sight.

This would be a more systems based approach than the LevelScripting to hide/show (enable/disable) enemies and terrain from the “Final Level” video.

2 Likes

Hey brosky, this is what i did …i know its not much but hope it helps:

public bool HaveLineOfSight(Vector3 position)

    //checking if there is anything btw the target and the enemy

    {

      int layerMask=8;

      layerMask=~layerMask;

       Vector3  direction=position-this.transform.position;

                  

            if(Physics.Raycast(this.transform.position,direction,currentWeaponConfig.GetRange(),layerMask))

            {

                return false;

            }

        return true;

    }

and this is how i implemented it in the fighter , but you can do the same for everything i guess…

private void Update()

    {

        timeSinceLastAttack += Time.deltaTime;

        if (target == null) return;

        if (target.IsDead()) return;

        if (!GetIsInRange(target.transform)||!HaveLineOfSight(target.transform.position))

        {

            GetComponent<Mover>().MoveTo(target.transform.position, 1f);

        }

        else

        {

            GetComponent<Mover>().Cancel();

            AttackBehaviour();

        }

    }

Privacy & Terms