Game Development Community

Object Selection Resource still not working for us.

by David Schwanke · in Torque Game Engine · 06/07/2004 (12:23 pm) · 1 replies

We're working at this diligently with each new piece of information that we come across by different people to get this to work. Lots of people claim out of the box functionality or near out of the box functionality with minimal changes for the new main engine version.

I have been able to track the problem down to a single line of code (atleast where its aparent there is something wrong) but I cant seem to get any further.

This is the code from serverCommandSelectObject in Commands.cs

%player = %client.player;   
if ($firstPerson)   
{     
   error("serverCmdSelectObject - RayCast w/ cPoint " @ %cameraPoint @ " rEnd " @ %rangeEnd @ " sMasks " @ %searchMasks @ " player " @ %player);
   
  [b] %scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks, %player);   [/b]
   
   error("scanTarg result : " @ %scanTarg);
}
else
 //3rd person - player is selectable in this case   
{
   error("serverCmdSelectObject - RayCast w/ cPoint " @ %cameraPoint @ " rEnd " @ %rangeEnd @ " sMasks " @ %searchMasks);
   
  [b] %scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %searchMasks);   [/b]
   
   error("scanTarg result : " @ %scanTarg);

}

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

The errors are my debuging code and shows me a little about what might be going on. But its the %scantarg = that seems to have problems.

The two basic test cases that I have are:

Clicking on an object a few feet in front of me in first person:

SelectObject called.
Mapping string: SelectObject to index: 3
serverCmdSelectObject - RayCast w/ cPoint 344.765 201.92 205.062 rEnd 544.599 201.559 196.931 sMasks 2048 player 1562
scanTarg result : 0

and clicking on myself in 3rd person point of view:

SelectObject called.
serverCmdSelectObject - RayCast w/ cPoint 341.947 201.956 205.148 rEnd 538.435 216.977 170.987 sMasks 2048
scanTarg result : 1562 343.901 202.105 204.808 -0.982438 -0.0751049 0.170805

As you can see the result of the scantarg zero in the first one is the failure to find an object. The result for the second one is the vector space or whatever of the found object I presume.

For completeness, this is the result of clicking on an aiplayer running around the map:

SelectObject called.
serverCmdSelectObject - RayCast w/ cPoint 428.818 271.75 223.14 rEnd 530.688 443.843 220.599 sMasks 2048 player 1562
scanTarg result : 1504 451.643 310.309 222.571 -0.50935 -0.860465 0.012705

So I know I can click on objects 'out in the open'.

Question that i have is that the ContainerRayCast is a TGE function, not something that I nor anyone else that I know of in my group has edited. So why would it return 0 for anything other then a Player object when we have the mask in the previous code section:

%searchMasks = $TypeMasks::ShapeBaseObjectType;

which is the parent object type of all of the objects we care about at the moment.

But even then we have tried manually adding objects such as ItemObjectType which is the type class of the objet that I clicked on for the test above. No luck.

Any ideas? I just get lost looking at the ContainerRayCast code and wonder why it would ever 'break down'?

Sorry to be a pain, I know these long winded problems arent the most fun. :)

#1
06/07/2004 (12:26 pm)
Oh and we implented all of the code and additions in the main resource and double checked the work. AND to my best I have checked to make sure there arent any moer 'blocking' gui elements suggested in another thread. (And I dont think there are by virtue of being able to click the running ai player a mile away but cant click a stack of ammo in the same screen space a few feet in front.

And thanks in advance for any help. This is starting to become a real stumper.