Diagonal line of sight with two corners
Posted
by
Ash Blue
on Game Development
See other posts from Game Development
or by Ash Blue
Published on 2013-05-31T06:34:18Z
Indexed on
2013/10/30
4:17 UTC
Read the original article
Hit count: 495
Right now I'm using Bresenham's line algorithm for line of sight. The problem is I've found an edge case where players can look through walls. Occurs when the player looks between two corners of a wall with a gap on the other side at specific angles.
The result I want is for the tile between two walls to be marked invalid as so.
What is the fastest way to modify Bresenham's line algorithm to solve this? If there isn't a good solution, is there a better suited algorithm? Any ideas are welcome. Please note the solution should also be capable of supporting 3d.
Edit: For the working source code and an interactive demo of the completed product please see http://ashblue.github.io/javascript-pathfinding/
© Game Development or respective owner