Game Development Community

Object selection help

by Randy Thomas · in Torque Game Engine · 08/14/2008 (10:04 pm) · 0 replies

I'm trying to get some objects in a project where a student can click on it in order for information to appear on the screen. I've been following the resource posted by Dave Myers ( http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2173 ) and I'm stuck. I think it's typeMask that's giving me the problem. For example: I have an object in the world called ladder. Script below:

new TSStatic(ladder) {
canSaveDynamicFields = "1";
position = "82.394 16.8811 99.3296";
rotation = "-1 0 0 13.1781";
scale = "1 1 1";
shapeName = "~/data/shapes/salem/ladder.dts";
receiveSunLight = "1";
receiveLMLighting = "1";
useAdaptiveSelfIllumination = "0";
useCustomAmbientLighting = "0";
customAmbientSelfIllumination = "0";
customAmbientLighting = "0 0 0 1";
useLightingOcclusion = "1";
onGroup = "Default Value";
TypeMask = "ItemObjectType";
};

Now if it want it clickable (as I read the instructions) I should have the following in commands.cs

function serverCmdSelectObject(%client, %mouseVec, %cameraPoint)
{
//Determine how far should the picking ray extend into the world?
%selectRange = 200;

//scale ouseVec to the range the player is able to select with mouse
%mouseScaled = VectorScale(%mouseVec, %selectRange);

//cameraPoint=the world position of the camera
//range Eng=camera point + length of selectable range
%rangeEnd = VectorAdd(%cameraPoint, %mouseScaled);

//Search for anything that is selectable – below are some examples
%searchMasks = $TypeMasks::ItemObjectTypes;

//Search for objects within the range that fit the masks above. If we are in first person
//mode, we make sure player is not selectable by setting fourth parameter
//(exempt from collisions) when calling ConatinerRayCast
%player = %client.player;

if($firstPerson)
{
%scanTart=ContainRayCast (%cameraPoint, %rangeEnd, %searchMasks, %player);
}
else //3rd person - player is selectable in this case
{
%scanTart = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks);
}

//a target in range was found so select it
if (%scanTarg)
{
%targetObject = firstWord(%scanTarg);
%client.setSelectedObject(%targetObject);
}
}


Does this look right to everyone When I go into starter.fps and hover my mouse over the object, nothing happens. I'm not getting the box. I've looked through the scripts from the tutorial and don't see anywhere that has a typo. Any suggestions or help would be greatly appreciated.

Thanks