public override void DetectEnemy()
        {
            base.DetectEnemy();

            Vector3 directionToSwordsMan = (SwordsMan.getInstance().transform.position - this.transform.position).normalized;

            Debug.DrawRay(this.transform.position, directionToSwordsMan * rayDistance, Color.red);
            Debug.DrawRay(this.transform.position, lookDirection * rayDistance, Color.yellow);
            Debug.DrawRay(this.transform.position, (lookDirection - fovDirectionLeft) * rayDistance, Color.yellow);
            Debug.DrawRay(this.transform.position, (lookDirection - fovDirectionRight) * rayDistance, Color.yellow);

            angleFormed = MathUtilities.AngleBetweenVectors(lookDirection.normalized, directionToSwordsMan);

            if (MathUtilities.AngleBetweenVectors(lookDirection.normalized, directionToSwordsMan) >= 0 &&
                MathUtilities.AngleBetweenVectors(lookDirection.normalized, directionToSwordsMan) <= (fovAngle))
            {
                Debug.DrawRay(this.transform.position, lookDirection * rayDistance, Color.green);
                Debug.DrawRay(this.transform.position, (lookDirection - fovDirectionLeft) * rayDistance, Color.green);
                Debug.DrawRay(this.transform.position, (lookDirection - fovDirectionRight) * rayDistance, Color.green);
            }
            else
            {
                Debug.DrawRay(this.transform.position, lookDirection * rayDistance, Color.yellow);
                Debug.DrawRay(this.transform.position, (lookDirection - fovDirectionLeft) * rayDistance, Color.yellow);
                Debug.DrawRay(this.transform.position, (lookDirection - fovDirectionRight) * rayDistance, Color.yellow);
            }
        }
Beispiel #2
0
    public void DetectEnemy()
    {
        Debug.DrawRay(this.transform.position, transform.forward * rayDistance, Color.yellow);
        Debug.DrawRay(this.transform.position, (lookDirection - fovDirection) * rayDistance, Color.yellow);
        Debug.DrawRay(this.transform.position, (lookDirection - (-fovDirection)) * rayDistance, Color.blue);

        Debug.Log(transform.eulerAngles.y);

        if (MathUtilities.AngleBetweenVectors(lookDirection.normalized, transform.forward) > fovAngle)
        {
            Debug.Log("Inside Field of View");
        }
    }
Beispiel #3
0
        public override void DetectEnemy()
        {
            base.DetectEnemy();

            Vector3 directionToSwordsMan = (SwordsMan.getInstance().transform.position - this.transform.position).normalized;

            Debug.DrawRay(this.transform.position, directionToSwordsMan * rayDistance, Color.yellow);
            Debug.DrawRay(this.transform.position, (lookDirection - fovDirection) * rayDistance, Color.yellow);
            Debug.DrawRay(this.transform.position, (lookDirection + (fovDirection)) * rayDistance, Color.blue);
            Debug.Log(transform.eulerAngles.y);

            if (MathUtilities.AngleBetweenVectors(lookDirection.normalized, directionToSwordsMan) >= 0 &&
                MathUtilities.AngleBetweenVectors(lookDirection.normalized, directionToSwordsMan) <= (fovAngle / 2))
            {
                enemyDetected = true;
            }
            else
            {
                enemyDetected = false;
            }
        }