private void OnSceneGUI()
        {
            CharacterVision vision = target as CharacterVision;

            Handles.color = Color.yellow;

            if (vision != null)
            {
                Handles.DrawWireArc(vision.transform.position, Vector3.up, Vector3.forward, 360, vision.ViewRadius);

                Vector3 viewAngleA = vision.DirectionFromAngle(-vision.ViewAngle / 2f, false);
                Vector3 viewAngleB = vision.DirectionFromAngle(vision.ViewAngle / 2f, false);

                Handles.color = Color.green;
                Handles.DrawLine(vision.transform.position, vision.transform.position + viewAngleA * vision.ViewRadius);
                Handles.DrawLine(vision.transform.position, vision.transform.position + viewAngleB * vision.ViewRadius);

                Handles.color = Color.red;

                foreach (Transform visibleTarget in vision.VisibleTargets)
                {
                    Handles.DrawLine(vision.transform.position, visibleTarget.position);
                }
            }
        }
Example #2
0
 void Awake()
 {
     animator  = GetComponentInChildren <Animator>();
     animation = GetComponentInChildren <Animation>();
     agent     = GetComponent <NavMeshAgent>();
     enemy     = GetComponent <Enemy>();
     Vision    = GetComponentInChildren <CharacterVision>();
 }
Example #3
0
    public virtual void Start()
    {
        //ignoreMask = (1 << LayerMask.NameToLayer("Obstacles")) | (1 << LayerMask.NameToLayer("Characters"));
        ignoreMask = 1 << LayerMask.NameToLayer("Characters");

        colFilter.useLayerMask = true;
        colFilter.SetLayerMask(ignoreMask);

        rb = GetComponent <Rigidbody2D>();

        if (vision == null)
        {
            vision = transform.Find("Vision").GetComponent <CharacterVision>();
        }

        health = maxHealth;
        healthBar.BuildHealtBar(maxHealth, !(type.Equals(CharacterType.PLAYER) || type.Equals(CharacterType.BOSS)));

        nextAttackBG = nextAttackBar.transform.parent.gameObject;

        sprite = GetComponentInChildren <SpriteRenderer>();
    }