Figuring out what object is closer to a certain point?

Posted by user1157885 on Game Development See other posts from Game Development or by user1157885
Published on 2013-10-18T23:27:22Z Indexed on 2013/10/19 4:14 UTC
Read the original article Hit count: 207

Filed under:

I'm trying to create fog of war, I have the visual effect created but I'm not sure how to deal with the hiding of other players if they're within the fog of war.

So right now the thing I'm trying to do is if another player is hiding behind a wall then not to render that player. I was thinking of doing it by sending a ray in the direction of all the players, and then creating a list of all the obstacles that ray collides with and then trying to figure out if an obstacle was closer than the player in order to predict the distance.

But then I realized I'm not really sure how to figure out if the obstacle is infact closer or not because I have to account for all the dimensions, so I'm kind of stuck. First of all is this approach the correct way to go about it and secondly how would I calculate if the obstacle was infact closer taking into account the X Y and Z.

Thanks

© Game Development or respective owner

Related posts about XNA