Game Development Community

Function "containerRayCast " with trouble

by Zhangbin · in Technical Issues · 12/18/2005 (5:49 am) · 1 replies

I want to do some "eye's picking" with following script code.

%startPoint = %client.player.getEyePoint();
%Vector = VectorScale(VectorNormalize(%client.player.getEyeVector()),100);
%endPoint = VectorAdd(%startPoint,%Vector);
%obj = GetWord(containerRayCast(%startPoint,%endPoint,0xffffffff,%client.player),0);
echo("========FindObject id:"@%obj@" | player id:"@%client.player@"=========");

Then ,i got the object id in "%obj",but it is not the object (type: TSStatic ) in the center of the player's screen, just the terrain block under it! Why?

About the author


#1
02/09/2006 (7:52 pm)
In the raycast line, there is a place to specify masks. In order for the cast to return a specific type of object, you must include the typemask of the object type you want to search for.

I believe these are all the standard typeMasks:

$TypeMasks::StaticObjectType
$TypeMasks::EnvironmentObjectType
$TypeMasks::TerrainObjectType
$TypeMasks::InteriorObjectType
$TypeMasks::WaterObjectType
$TypeMasks::TriggerObjectType
$TypeMasks::MarkerObjectType
$TypeMasks::GameBaseObjectType
$TypeMasks::ShapeBaseObjectType
$TypeMasks::CameraObjectType
$TypeMasks::StaticShapeObjectType
$TypeMasks::PlayerObjectType
$TypeMasks::ItemObjectType
$TypeMasks::VehicleObjectType
$TypeMasks::VehicleBlockerObjectType
$TypeMasks::ProjectileObjectType
$TypeMasks::ExplosionObjectType
$TypeMasks::CorpseObjectType
$TypeMasks::DebrisObjectType
$TypeMasks::PhysicalZoneObjectType
$TypeMasks::StaticTSObjectType
$TypeMasks::StaticRenderedObjectType
$TypeMasks::DamagableItemObjectType

So for your function, you could specify iy like so:
%obj = GetWord(containerRayCast(%startPoint,%endPoint,$TypeMasks::StaticTSObjectType,%client.player),0);

Of course you are not limited to using only one type mask. you could specify a mask like so:

%mask = ($TypeMasks::VehicleObjectType | $TypeMasks::MoveableObjectType |
         $TypeMasks::StaticShapeObjectType | $TypeMasks::InteriorObjectType | 
         $TypeMasks::ItemObjectType);

Then simply insert the variable %mask into the rayCast.