seePlayer method
Shape?
seePlayer({
- required dynamic observed(),
- VoidCallback? notObserved,
- double radiusVision = 32,
- double? visionAngle,
- double? angle,
This method we notify when detect the player when enter in radiusVision
configuration
Method that bo used in update method.
visionAngle
in radians
angle
in radians. is automatically picked up using the component's direction.
Implementation
Shape? seePlayer({
required Function(Player) observed,
VoidCallback? notObserved,
double radiusVision = 32,
double? visionAngle,
double? angle,
}) {
Player? player = gameRef.player;
if (player == null || player.isDead) {
notObserved?.call();
return null;
}
return seeComponent(
player,
observed: (c) => observed(c as Player),
notObserved: notObserved,
radiusVision: radiusVision,
visionAngle: visionAngle,
angle: angle ?? lastDirection.toRadians(),
);
}