Skip to content

has_line_of_sight: ZeroDivisionError #1934

Closed
@einarf

Description

@einarf

When the distance between two positions are zero we get a ZeroDivisionError.

  File "D:\Documents\project\HorrorGame\ghost.py", line 33, in can_see_player
    return arcade.has_line_of_sight(self.position, player.position, walls, 200, 5)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\project\HorrorGame\Lib\site-packages\arcade\paths.py", line 357, in has_line_of_sight
    u = step_distance / distance
        ~~~~~~~~~~~~~~^~~~~~~~~~
ZeroDivisionError: float division by zero

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions