Game Development Community

Object selection in Torque (v1.2 onward) question

by Jacob · in Torque Game Engine · 05/11/2005 (5:11 pm) · 10 replies

The resource in question is here.

I just started playing with this in my game and it isn't working for me. It seems that Sim::findObject inside the console method setSelectedObject is returning false, as if it din't find the object I selected? - thus not selecting the object I clicked upon. I made sure that the object (its id) IS being passed into this function. What did I miss here? Thanks!

#1
05/12/2005 (6:15 pm)
Are you using it over a network or something?

What if you try to reference the ID manually, ie, 2342.dump() ?
#2
05/13/2005 (8:11 am)
No network Ben...The interesing thing to me is that I can plug the object id as the first arg in the Sim::findObject call and it still is returning false.

Here is the result of dump(); :

==>2507.dump();
Member Fields:
  interiorFile = "Game/data/interiors/homeislandcottage.dif"
  position = "567.909 -764.872 51.4248"
  rotation = "1 0 0 0"
  scale = "1 1 1"
  showTerrainInside = "0"
Tagged Fields:
Methods:
  activateLight() - 
  clearScopeToClient() - 
  deactivateLight() - 
  delete() - 
  dump() - 
  echoTriggerableLights() - 
  getClassName() - 
  getForwardVector() - 
  getGhostID() - 
  getGroup() - 
  getId() - 
  getName() - 
  getNumDetailLevels() - 
  getObjectBox() - 
  getPosition() - 
  getScale() - 
  getTransform() - 
  getType() - 
  getWorldBox() - 
  getWorldBoxCenter() - 
  magicButton() - 
  save() - 
  schedule() - 
  scopeToClient() - 
  setAlarmMode() - 
  setDetailLevel() - 
  setName() - 
  setScale() - 
  setScopeAlways() - 
  setSkinBase() - 
  setTransform() -
#3
05/13/2005 (11:11 pm)
I would guess you're somehow passing the wrong thing to findObject, as the 1234.dump() call involves doing a findObject lookup and seems to work...
#4
05/14/2005 (7:16 am)
Here is the function in gameconnection.cc that is in question:

ConsoleMethod( GameConnection, setSelectedObject, bool, 3, 3, "(%object)")
{
   ShapeBase *sb;

      if(!Sim::findObject(argv[2], sb))   
         return false;

   object->setSelectedObject(sb);

   return true;
}

I have checked and argv[2] is 2507...any ideas? Thank You.
#5
05/14/2005 (5:07 pm)
Which GameConnection are you calling that on?
#6
05/14/2005 (5:18 pm)
This is straight from the resource to which there is a link in my original post. To answer your question then - not sure :)
#7
05/15/2005 (4:18 am)
I scanned it very quickly but I didn't see where they were accessing a GameConnection via scripts...just in C++ which would never touch the function you posted above.
#8
05/15/2005 (4:41 am)
@Matt:

in server/commands.cs function serverCmdSelectObject(...) before the last brace (})

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

-Ron
#9
05/15/2005 (5:33 am)
Ah right =) Seems I scanned too quickly!

Hmm....I will attempt to implement this resource tomorrow if I get a chance and see if I can reproduce your bug. At this point I would recommend that you go over this resource and your implementation with a fine tooth comb to make sure you didn't skip anything. The fact that it has worked for a number of people before you would seem to indicate that you just missed something.
#10
05/15/2005 (7:32 am)
I am grateful for all your help! I went through the code to make sure I didn't miss anything and it seems that I did not...so, I thought of just calling worldEditor.selectObject whenever an object is clicked to select it but this wouldn't place the bounding box around it during the game - which is what I was hoping. I am using the newest LP also, if anyone thinks it could have something to do with this not working.