// PRAGMA MARK - Internal private void HandleBattlePlayerShotLaser(Laser laser, BattlePlayer battlePlayer) { if (battlePlayer == StateMachine_.Player) { return; } // NOTE (darren): do calculations in XZ space because height doesn't matter in PHASERBEAK Vector2 laserDirection = laser.transform.forward.Vector2XZValue(); Vector2 laserToSelfVector = (StateMachine_.Player.transform.position - laser.transform.position).Vector2XZValue(); float angleDistance = Vector2.Angle(laserDirection, laserToSelfVector); if (angleDistance > 30.0f) { return; } StateMachine_.Dash(GenerateValidDashDirection()); }
protected override void OnStateUpdated() { if (target_ == null || !BattlePlayer.ActivePlayers.Contains(target_)) { StateMachine_.SwitchState(AIStateMachine.State.Idle); return; } Vector2 playerToTargetVector = BattlePlayerUtil.XZVectorFromTo(StateMachine_.Player, target_); Vector2 targetDirection = playerToTargetVector.normalized; if (playerToTargetVector.magnitude <= predictedDashDistance_) { StateMachine_.Dash(targetDirection); } else { StateMachine_.InputState.LerpMovementVectorTowards(targetDirection); } }