I spent some time today optimizing and modularizing the script I've been using to prepare it for having more than one player character. I also moved the mini map to an overlay scene.
Finally I started doing some tests on LOS.
Originally I had thought of using raycasting LOS, as this is a 3d game, I may as well take advantage of the power of a modern PC right? But after some consideration I'll be using the Bresenham line drawing algorithm to check for line of sight in the game and I've also been thinking of how I can use it in path finding. It is rather a nice algorithm and the worst part about it I can see is that it sometimes draws rather ugly lines when they veer near to the vertical or horizontal.
Here's an example of the LOS in game:
It's just an illustration of course so in the final game there won't be any indicators, the slime will just not be visible to the player. the beauty of using this implementation is that I don't have to do any ray-casting. I just check the walk dictionary (which includes both walkable squares and flyable squares) for each enemy in range and if any point on the line is not in the dictionary the chosen object is not visible.
I've read a little about using the algorithm for pathfinding too,but I'm not sure I'll be able to get it to work with non diagonal movement (which is a corner stone of my game). Lets wait and see.
EDIT: After some experiments I've decided that diagonal movement is perhaps OK after all. I'll be doing some fixes to make sure that players and enemies don't try to cut corners through the scenery, but most of that should be possible to handle by modifying the walk meshes anyway. The Line algorithm works really well with pathfinding creating fairly natural looking diagonal paths and cutting down on processing time a lot compared to A*. One thing I specifically want to avoid is players or enemies squeezing between a wall corner and another player/NPC or moving diagonally in to a square which can't be reached by regular NSEW movement.
Finally I started doing some tests on LOS.
Originally I had thought of using raycasting LOS, as this is a 3d game, I may as well take advantage of the power of a modern PC right? But after some consideration I'll be using the Bresenham line drawing algorithm to check for line of sight in the game and I've also been thinking of how I can use it in path finding. It is rather a nice algorithm and the worst part about it I can see is that it sometimes draws rather ugly lines when they veer near to the vertical or horizontal.
Here's an example of the LOS in game:
It's just an illustration of course so in the final game there won't be any indicators, the slime will just not be visible to the player. the beauty of using this implementation is that I don't have to do any ray-casting. I just check the walk dictionary (which includes both walkable squares and flyable squares) for each enemy in range and if any point on the line is not in the dictionary the chosen object is not visible.
I've read a little about using the algorithm for pathfinding too,
EDIT: After some experiments I've decided that diagonal movement is perhaps OK after all. I'll be doing some fixes to make sure that players and enemies don't try to cut corners through the scenery, but most of that should be possible to handle by modifying the walk meshes anyway. The Line algorithm works really well with pathfinding creating fairly natural looking diagonal paths and cutting down on processing time a lot compared to A*. One thing I specifically want to avoid is players or enemies squeezing between a wall corner and another player/NPC or moving diagonally in to a square which can't be reached by regular NSEW movement.
Comments
Post a Comment