Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: player.seeEnemy() cannot see enemies hidden by attack components #455

Closed
CubeDr opened this issue Oct 24, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@CubeDr
Copy link

CubeDr commented Oct 24, 2023

What happened?

I'm auto-targeting the enemies and firing range attacks.

Since attacks are FlyingAttackGameObject, they hide the enemies and the player cannot see the enemy when the attack is flying to the enemy.

Steps to reproduce?

  1. Find the enemy with seeEnemy()
  2. Get the angle with angleTo()
  3. fire range attack with simpleAttackRangeByAngle()
@override
void fire(Player player, Weapon weapon) async {
  if (player.isDead) return;

  player.simpleAttackRangeByAngle(
    speed: 200,
    angle: await _getFireAngle(player) - pi / 2,
    damage: _damage,
    animation: AnimationConfigs.shurikenMagicAnimation(),
    size: _size,
    attackFrom: AttackFromEnum.PLAYER_OR_ALLY,
    collision: CircleHitbox(
      radius: _radius,
      position: Vector2.zero(),
      collisionType: CollisionType.passive,
    ),
  );
}
Future<double> _getFireAngle(Player player) {
  final completer = new Completer<double>();
  player.seeEnemy(
    radiusVision: 2000,
    observed: (List<Enemy> enemies) {
      double distance = double.infinity;
      Enemy closetEnemy = enemies[0];
      for (final enemy in enemies) {
        double d = player.distance(enemy);
        if (d < distance) {
          distance = d;
          closetEnemy = enemy;
        }
      }
      completer.complete(player.angleTo(closetEnemy.position));
    },
  );
  return completer.future;
}

What did you expect to happen?

Only fire range attacks to the closest enemy.

Bonfire version

Release 3.0.0

Relevant log output

No response

@CubeDr CubeDr added the bug Something isn't working label Oct 24, 2023
@CubeDr
Copy link
Author

CubeDr commented Oct 24, 2023

I was able to bypass the issue by disabling the raycast check with setupVision(checkWithRaycast: false);.

However, I think having an option to prevent projectiles from blocking the sight will greatly improve the framework.

Thanks, bonfire team!

@RafaelBarbosatec
Copy link
Owner

RafaelBarbosatec commented Oct 26, 2023

It's not a bug. You found the configuration to disable check with raycast.
I will think in how way to adds this options of prevent some tiles or objects.

@RafaelBarbosatec
Copy link
Owner

Fixed in version 3.0.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants