Game Development Community

Remove Item from Scene without Deletion?

by Chad Kilgore · in Torque Game Engine · 05/23/2007 (4:52 pm) · 5 replies

Is it possible to remove an item from the scene without using %obj.delete()? Effectively, can one store the item like:
$Item = %obj;
%obj.remove();
and then reintroduce that object back to the scene later? Thanks.

#1
05/23/2007 (5:41 pm)
You could always just try

%obj.setHidden(true);

This will hide the object, including its collision mesh, so it's basically like the object isn't there anymore. But it is, just use setHidden(false) to make it re-appear.
#2
05/24/2007 (7:28 am)
$Item=obj.getDatablock();
  %obj.delete;

Later create item with stored datablock on the place you wish
%item= new Item() 
  {
        position = %pos;
        rotation = %rot;
        scale = "1 1 1";
        dataBlock = $Item;
        collidable = "0";
        static = "0";
        rotate = "0";
        Ammount = "1";
  };
#3
05/24/2007 (10:13 am)
On the C++ side there are two functions in SceneObject.

/// Adds object to the client or server container depending on the object
   void addToScene();

   /// Removes the object from the client/server container
   void removeFromScene();

If you wanted to control this from script you would have to expose the methods to the console. I haven't tried to do this yet, but i will be soon enough.
#4
05/25/2007 (4:57 pm)
void removeFromScene();

appears to remove the collision mesh from the scene; however, the object is still rendered. Any suggestions on how to remove the render?
#5
05/25/2007 (5:52 pm)
Really? That seems strange to me... i would think that is a bug of some sort.