Game Development Community

How to get only desired type of object when click

by Paulo Coutinho · in Torque Developer Network · 12/14/2009 (1:58 am) · 0 replies

Hi,

How i can search for only one type of object when i click? And if i get different object type, it return 0 or false.

Now im using it to get the ground object:

## CODE ##

// Make the ray
%ray = VectorScale(%ray, 1000);
%end = VectorAdd(%start, %ray);

// Verify if the player select to build a construction
if ($Player::buildTowerSelected)
{
// verify if hit the ground
%searchMasks = $TypeMasks::StaticTSObjectType; //type
%scanTarg = ContainerRayCast( %start, %end, %searchMasks );

if( %scanTarg )
{
$Player::buildTowerSelected = false;

//get mouse data
$Mouse::posX = getWord(%scanTarg,0);
$Mouse::posY = getWord(%scanTarg,1);
$Mouse::posVector = getWords(%scanTarg, 1, 3);

commandToServer('buildTower', $Mouse::posVector);

return;
}
}

## PROBLEM ##

The problem is that if i have a player/construction and under the ground, so %scanTarg return the mouse position.

To solve it, i have to check player type object and constructions objects before search for ground. But if i have do it for all my function that i only want search for one type of object, will cost more process time/memory.

So my question is: How to know the position ONLY WHEN i click on DESIRED object type(on my case: $TypeMasks::StaticTSObjectType), if other objects type found when click, %scanTarg have to be 0 or false.