public bool SearchForTarget(int mode) { // Motion-Sensing Mode if (mode == 0) { if (playerOldPos != playerCurrPos) { return(true); } else { return(false); } } // Seachlight Mode else { Vector3 vecToPlayer = playerCurrPos - bc.rb.position; float dp = Vector3.Dot(DirectionUtil.DirToVector(bc.facing), vecToPlayer.normalized); float angle = Mathf.Acos(dp); int walllayer = 9; // fill in with the layer # of anything that obstructs enemy vision if (angle <= bc.fieldOfView) { if (!Physics.Raycast(bc.rb.position, vecToPlayer, vecToPlayer.magnitude, (1 << walllayer))) { return(true); } } return(false); } }
public Attacking(BossController mybc) { bc = mybc; player = GameObject.FindGameObjectWithTag("Player"); facing = DirectionUtil.DirToVector(bc.facing); // facing = (player.transform.position - bc.gameObject.transform.position).normalized; facing.y = 0; attackDuration = 0.5f; attackTimer = 0; numHitboxes = activateHitboxMoments.Length; hitboxes = new GameObject[numHitboxes]; damage = 30; }