arguments for this function
by Robert Rourks · in Torque Game Engine · 12/01/2002 (4:31 pm) · 2 replies
The function below is in fps/server/scripts/commnds.cs it requires 3 arguments, and i cant figure out where to get the last 2
function serverCmdSelectObject(%client, %mouseVec, %cameraPoint)
{
//Determine how far should the picking ray extend into the world?
%selectRange = 200;
// scale mouseVec to the range the player is able to select with mouse
%mouseScaled = VectorScale(%mouseVec, %selectRange);
// cameraPoint = the world position of the camera
// rangeEnd = camera point + length of selectable range
%rangeEnd = VectorAdd(%cameraPoint, %mouseScaled);
// Search for anything that is selectable below are some examples
%searchMasks = $TypeMasks::PlayerObjectType | $TypeMasks::CorpseObjectType |
$TypeMasks::ItemObjectType | $TypeMasks::TriggerObjectType;
// 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 ContainerRayCast
%player = %client.player;
if ($firstPerson)
{
%scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks, %player);
}
else //3rd person - player is selectable in this case
{
%scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks);
}
// a target in range was found so select it
if (%scanTarg)
{
%targetObject = firstWord(%scanTarg);
%client.setSelectedObj(%targetObject);
}
}
%mouseVec and %camPos. I cant figure out how to get these two from the client, any ideas? I already posted about this earlier, hopefuly seeing what i need it for will come someone some ideas for where to get these values from. Thanks
function serverCmdSelectObject(%client, %mouseVec, %cameraPoint)
{
//Determine how far should the picking ray extend into the world?
%selectRange = 200;
// scale mouseVec to the range the player is able to select with mouse
%mouseScaled = VectorScale(%mouseVec, %selectRange);
// cameraPoint = the world position of the camera
// rangeEnd = camera point + length of selectable range
%rangeEnd = VectorAdd(%cameraPoint, %mouseScaled);
// Search for anything that is selectable below are some examples
%searchMasks = $TypeMasks::PlayerObjectType | $TypeMasks::CorpseObjectType |
$TypeMasks::ItemObjectType | $TypeMasks::TriggerObjectType;
// 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 ContainerRayCast
%player = %client.player;
if ($firstPerson)
{
%scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks, %player);
}
else //3rd person - player is selectable in this case
{
%scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks);
}
// a target in range was found so select it
if (%scanTarg)
{
%targetObject = firstWord(%scanTarg);
%client.setSelectedObj(%targetObject);
}
}
%mouseVec and %camPos. I cant figure out how to get these two from the client, any ideas? I already posted about this earlier, hopefuly seeing what i need it for will come someone some ideas for where to get these values from. Thanks
About the author
Associate Stefan Beffy Moises