SpatialFear.SFDirectionTrigger

00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
//=============================================================================
// Spatial Fear
// Class: SFDirectionTrigger
// Descritption: A trigger, that only fires, when the instigator is within a 
//					predefined direction (arc) to the location of the trigger
//
// Author: Markus Nuebel
//=============================================================================

class SFDirectionTrigger extends SFTrigger;

var (SpatialFear) float fThreshold; // Treshold for the dot product. e.g.1=has to be triggered directly from in front, 0=can be triggered from anywhere in an 180 degree FOV of the trigger, 0.7=equals a test for a 45 degree FOV of the trigger.

singular function Touch(Actor Other)
{
	local Vector X, Y, Z;
	local float fDot;

	local bool bResult;

	bResult	= True;

	// should we even pay attention to this actor?
	if (!IsRelevant(Other))
		return;

	if (Other != None)
	{
		GetAxes(Rotation, X, Y, Z);
		fDot	= (Normal(Other.Location - Location)) dot X;
		// if we're on the wrong side of the trigger, then don't trigger it
		if (fDot < fThreshold)
			bResult = False;
	}

	if (bResult)
		Super.Touch(Other);
}

defaultproperties
{
     ReTriggerDelay=1.000000
     bDirectional=True
}

class file time: 12/7/2003 3:58:24 PM - creation time: 12/7/2003 4:03:44 PM
Created with UnCodeX