I need to do some visibility test to implement node based path finding. I don’t know the exact name of it, but the idea I have in mind is this.
- Developer places movement nodes around the map by hand, in a certain manner so that every node can see at least one another node;
- When doing movement, check if destination point is visible. If it is, just walk to it in a straight line;
- If it isn’t do some kind of node based pathfinding algorithm and work out shortest node path to destination point, or something like that…
One big problem I can see incoming is checking if the node is visible. I have node idea how to do it properly. Here is a simple illustration showing what I want to accomplish if you don’t understand…
On one of my previous games I implement vision by doing something like this:
- Pick a starting point and destination point. Compute x,y increments so each increment is of specific length, lets say increment length = 1;
- Add those increment values to starting position, until starting position is equal to destination position;
- After each increment check if current position on the level is a visible point. If not, the path is not visible.
I guess this is called ray casting or something like that. The problem I see coming with this already is that it would be reallllyyyyyyyy slow if I computed visibility check many times. Are there better ways to compute visibility, or should I also calculate which nodes are visible by a certain node before the game begins so that each nodes know which nodes it can see, since those nodes wouldn’t change positions.