TGB 1.5.1 Clone and Group problem
by David House · in Torque Game Builder · 11/10/2007 (5:19 am) · 1 replies
When you clone an object, the code is not setting the mGraphGroupMask member variable at all. So what happens is that cloned objects default to Group 0. If you are trying to use the Collision Group stuff, it will not work as you expect. The simple workaround is to set the Group manually after the clone. Here is an example of my clone method:
If you look at the setGraphGroup function in t2dSceneObject, you find this line:
But in the copyTo method, mGraphGroupMask is not being copied or set. So your cloned object goes to group 0 by default.
function createClone(%this,%name,%pos)
{
eval( "%newEnemy = " @ %name @ ".cloneWithBehaviors();");
%template = %newEnemy.getBehavior("TemplateBehavior");
%newEnemy.removeBehavior(%template);
%newEnemy.position = %pos;
%newEnemy.GraphGroup = "2";
%newEnemy.onAddToScene(%this.object.scenegraph);
}If you look at the setGraphGroup function in t2dSceneObject, you find this line:
// Set Group Mask.
mGraphGroupMask = BIT( mGraphGroup );But in the copyTo method, mGraphGroupMask is not being copied or set. So your cloned object goes to group 0 by default.
About the author
Associate James Ford
Sickhead Games