• Create Account

Posted 23 March 2013 - 01:39 PM

I don't understand why you use velocity for this. If your velocity is zero, you can't normalise it.

Normally a FOV check is done by taking the dot product between your (normalised) relative position from an enemy and their facing direction.

The dot product of 2 normalised vectors returns the cosine of the angle between them (angle is in radians of course), the check is normally something like

if(dot(normalisedRelativePosition, enemyFacing) >= cos(HalfAngleOfVisionConeInRadians)) /* in cone of vision */;

The check uses >= since with a 0 radian view angle you are only visible if your position is dead ahead of the enemy facing (i.e. the dot product is 1, which is cos(0)), and if the angle is pi then you are always in the cone of vision (since cos(pi) = -1).

EDIT: Note - the cone angle is the half angle (i.e. angle from the direction vector to the cone edge).

EDIT2: Several corrections ;)

Posted 23 March 2013 - 01:34 PM

I don't understand why you use velocity for this. If your velocity is zero, you can't normalise it.

Normally a FOV check is done by taking the dot product between your (normalised) relative position from an enemy and their facing direction.

The dot product of 2 normalised vectors returns the cosine of the angle between them (angle is in radians of course), the check is normally something like

if(dot(normalisedRelativePosition, enemyFacing) >= cos(HalfAngleOfVisionConeInRadians)) /* in cone of vision */;

The check uses >= since with a 0 radian view angle you are only visible if your position is dead ahead of the enemy facing, and if the angle is pi then you are always in the cone of vision.

EDIT: Note - the cone angle is the half angle (i.e. angle from the direction vector to the cone edge).

EDIT2: Several corrections ;)

Posted 23 March 2013 - 01:34 PM

I don't understand why you use velocity for this. If your velocity is zero, you can't normalise it.

Normally a FOV check is done by taking the dot product between your (normalised) relative position from an enemy and their facing direction.

The dot product of 2 normalised vectors returns the cosine of the angle between them (angle is in radians of course), the check is normally something like

if(dot(normalisedRelativePosition, enemyFacing) >= cos(HalfAngleOfVisionConeInRadians)) /* in cone of vision */;

The check uses >= since with a 0 radian view angle you are only visible if your position is dead ahead of the enemy facing, and if the angle is pi then you are always in the cone of vision.

EDIT: Note - the cone angle is the half angle (i.e. angle from the direction vector to the cone edge).

Posted 23 March 2013 - 01:34 PM

I don't understand why you use velocity for this. If your velocity is zero, you can't normalise it.

Normally a FOV check is done by taking the dot product between your (normalised) relative position from an enemy and their facing direction.

The dot product of 2 normalised vectors returns the cosine of the angle between them (angle is in radians of course), the check is normally something like

if(dot(normalisedRelativePosition, enemyFacing) >= cos(cosineOfVisionConeInRadians)) /* in cone of vision */;

The check uses >= since with a 0 radian view angle you are only visible if your position is dead ahead of the enemy facing, and if the angle is pi then you are always in the cone of vision.

EDIT: Note - the cone angle is the half angle (i.e. angle from the direction vector to the cone edge).

Posted 23 March 2013 - 01:32 PM

I don't understand why you use velocity for this. If your velocity is zero, you can't normalise it.

Normally a FOV check is done by taking the dot product between your (normalised) relative position from an enemy and their facing direction.

The dot product of 2 normalised vectors returns the cosine of the angle between them (angle is in radians of course), the check is normally something like

if(dot(normalisedRelativePosition, enemyFacing) >= cos(cosineOfVisionConeInRadians)) /* in cone of vision */;

The check uses >= since with a 0 radian view angle you are only visible if your position is dead ahead of the enemy facing, and if the angle is 2pi then you are always in the cone of vision.

Posted 23 March 2013 - 01:31 PM

I don't understand why you use velocity for this. If your velocity is zero, you can't normalise it.

Normally a FOV check is done by taking the dot product between your (normalised) relative position from an enemy and their facing direction.

The dot product of 2 normalised vectors returns the cosine of the angle between them (angle is in radians of course), the check is normally something like

if(dot(normalisedRelativePosition, enemyFacing) >= cos(cosineOfVisionConeInRadians)) /* in cone of vision */;

The check uses >= since a 0 radian view angle is only visible if your position is dead ahead of the enemy facing, and if the angle is 2pi then you are always in the cone of vision.

PARTNERS