•      Sign In
• Create Account

#Actualslicer4ever

Posted 12 April 2012 - 02:24 PM

since you are only doing a single ray testing, it's extremely easy to test line of sight.

psedo-code:
void LineOfSight(PlayerPosition, EnemyPosition){
pointA = EnemyPosition;
pointB = PlayerPosition;
for(i=0;i<NbrObstacles;i++){
//Check linexObstacle(if your using rectangle's look up linexRectangle, for all simple shapes, their's simple formula, for complex shapes, you simple loop though all the edges, and check linexPlane(in 2D, it's basically linexline collision).)
if(IntersectionWithObstacleI) PointB = Intesect location; //(if we just care if the other tank can't see the player, you could return false for a line of sight function here.
}
return PointB==PlayerPosition?1:0;
}


that's the jist of it, for line of sight with cones/complex vision's, then it gets quite a bit more complicated.

#2slicer4ever

Posted 12 April 2012 - 02:23 PM

since you are only doing a single ray testing, it's extremely easy to test line of sight.

psedo-code:
void LineOfSight(PlayerPosition, EnemyPosition){
pointA = EnemyPosition;
pointB = PlayerPosition;
for(i=0;i<NbrObstacles;i++){
//Check linexObstacle(if your using rectangle's look up linexRectangle, for all simple shapes, their's simple formula, for complex shapes, you simple loop though all the edges, and check linexPlane(in 2D, it's basically linexline collision).)
if(IntersectionWithObstacleI) PointB = Intesect location(if we just care if the other tank can't see the player, you could return false for a line of sight function here.
}
return PointB==PlayerPosition?1:0;
}


that's the jist of it, for line of sight with cones/complex vision's, then it gets quite a bit more complicated.

#1slicer4ever

Posted 12 April 2012 - 02:22 PM

since you are only doing a single ray testing, it's extremely easy to test line of sight.

psedo-code:
void LineOfSight(PlayerPosition, EnemyPosition){
pointA = EnemyPosition;
pointB = PlayerPosition;
for(i=0;i<NbrObstacles;i++){
//Check linexObstacle(if your using rectangle's look up linexRectangle, for all simple shapes, their's simple formula, for complex shapes, you simple loop though all the 	     edges, and check linexPlane(in 2D, it's basically linexline collision).)
if(IntersectionWithObstacleI) PointB = Intesect location(if we just care if the other tank can't see the player, you could return false for a line of sight function here.
}
return PointB==PlayerPosition?1:0;
}


that's the jist of it, for line of sight with cones/complex vision's, then it gets quite a bit more complicated.

PARTNERS