Abount removeFromScene
by Hugeone · in Torque Game Builder · 04/10/2006 (6:54 pm) · 1 replies
HI:
Here is my code.
function t2dSceneObject::onCollision( %srcCollisionObject, %dstCollisionObject,
%srcRef, %dstRef, %collisionTime, %collisionNormal,
%contactCount, %contactPoints )
{
%srcCollisionObject.removeFromScene( );
}
but , as soon as collision happen, program crash. I want to know when and where is safe to invoke removeFromScene( ) ?
regards
hugeone
Here is my code.
function t2dSceneObject::onCollision( %srcCollisionObject, %dstCollisionObject,
%srcRef, %dstRef, %collisionTime, %collisionNormal,
%contactCount, %contactPoints )
{
%srcCollisionObject.removeFromScene( );
}
but , as soon as collision happen, program crash. I want to know when and where is safe to invoke removeFromScene( ) ?
regards
hugeone
Torque Owner Alexander Bierbrauer
There's a method called setCollisionActive which gets two options if the object should send and RECEIVE onCollision-Callbacks... maybe that's your problem?
Another solution maybe something like this:
function t2dSceneObject::onCollision( %srcCollisionObject, %dstCollisionObject,
%srcRef, %dstRef, %collisionTime, %collisionNormal,
%contactCount, %contactPoints )
{
%srcCollisionObject.deleteOnNextUpdate = true;
}
function t2dSceneObject::onUpdate(somewhat)
{
for(objects)
{
if(object[x].deleteOnNextUpdate == true)
{
%(object[x].removeFromScene( );
%(object[x].safeDelete( );
}
}
}
Hope you got the principle behind my idea.
Alex