Raycast terrain issue
by Howard Dortch · in Torque 3D Professional · 11/02/2010 (7:56 pm) · 2 replies
I am trying to do a line of sight test between 2 objects. I have the mask set to $TypeMasks::StaticShapeObjectType. I place one object in plain sight of the other and cast a ray and echo "HIT"... all is well.. I move one object over a hill so I can't see the other one, do the raycast and I still get a "HIT" it's like the terrain isn't there. Anyone know what the trick is to make the terrain occlude the raycast ?
Associate Steve Acaster
[YorkshireRifles.com]
eg:
$Obstacles = $TypeMasks::VehicleObjectType | $TypeMasks::PlayerObjectType | $TypeMasks::TerrainObjectType | $TypeMasks::StaticTSObjectType | $TypeMasks::StaticShapeObjectType | $TypeMasks::ForestObjectType; // InteriorObjectType removed function ClearView(%this, %obj) { if(!isObject(%obj)) return false; %start = %this.getTransform(); %end = %obj.getTransform(); %targetsearch = containerRayCast(%start, %end, $Obstacles, %this.getID()); %impactpoint = firstWord(%targetsearch); if(%impactpoint.getClassName() $="StaticShape") { echo("HIT Staticshape!"); return true; } else { echo("Missed StaticShape - has hit " @ %impactpoint.getClassName()); return false; } }