Problem removing mounted object from the scene
by darkwudu · in Torque X Platformer Kit · 08/26/2008 (3:41 pm) · 1 replies
I am having some serious troubles removing a mounted object from my scene. I'm guessing the problem is something small (it usually is!) but I have spent far too much time trying to find a solution to this myself and really need some help from someone more experienced! :)
I have an enemy in my scene, "Enemy".
I have a spawner mounted to my object, "ActionTriggerSpawn".
The "ActionTriggerSpawn" spawns the object "ActionTrigger". This causes an action to happen when the player collides with it.
I have a projectile which, when fired, kills the "Enemy" using ActorComponent.Kill, but the "ActionTrigger" object is left behind, performing the action whenever the player enters the space which it occupied (the projectile has a KillTrigger component attached).
I have tried adding the following code to the KillTrigger...
I get the error "TorqueObject.MarkForDelete - Cannot mark object for delete if not added to database."
I was under the impression that the ActorComponent.Kill method deleted the actor, and therefore any mounted objects along with it. Is this not the case? Is there another way I should be trying?
I have an enemy in my scene, "Enemy".
I have a spawner mounted to my object, "ActionTriggerSpawn".
The "ActionTriggerSpawn" spawns the object "ActionTrigger". This causes an action to happen when the player collides with it.
I have a projectile which, when fired, kills the "Enemy" using ActorComponent.Kill, but the "ActionTrigger" object is left behind, performing the action whenever the player enters the space which it occupied (the projectile has a KillTrigger component attached).
I have tried adding the following code to the KillTrigger...
T2DSceneObject actionTrigger = TorqueObjectDatabase.Instance.FindObject<T2DSceneObject>("ActionTrigger");
if (actionTrigger == null)
return;
actionTrigger.MarkForDelete = true;I get the error "TorqueObject.MarkForDelete - Cannot mark object for delete if not added to database."
I was under the impression that the ActorComponent.Kill method deleted the actor, and therefore any mounted objects along with it. Is this not the case? Is there another way I should be trying?
About the author
Torque Owner darkwudu
I added Owner.MarkForDelete = true to the ActorComponent.Kill which now removes both the Enemy and its mounted objects.