Game Development Community

CloneWithBehaviors() issue?

by C Martin · in Torque Game Builder · 09/07/2008 (6:19 am) · 2 replies

Hi all,

Hope this is an appropriate place for this:

I've been trying to get a simple app up and running that spawns enemies around a central character, very much like the Asteroids/Astral Objects tutorial. However, I was getting an issue with the tutorial where the score would continually increment on spawning of a character. It seems as though the onRemoveFromScene event was being triggered whenever a characters was spawned. This was odd, so to debug this I made a simpler project.

I first place an object in the level and give it a template behavior. Then I add a SceneObject and give it the "SpawnArea" behavior. I've given them appropriate names, then run the app.

I keep getting an error on the console "t2dsceneGraph::addToScene() - object '' is already in a SceneGraph!" error everytime an object spawns in the level.

This is using nothing more than the SpawnArea behavior and the Template behaviors from TDN behaviors page. It seems that this error is being generated by the call to "%this.object.cloneWithBehaviors();"

I'm using TGB 1.7.4 on Windows Vista 32.

Any comments would be appreciated, this issue has kinda put me on hold...

#1
09/08/2008 (4:21 am)
Easiest way to replicate this:


Clean install of TGB - load the Behaviors Playground level - then choose to open a new scene (the default scene is not useful here). Select the asteroids scene that comes with the TGB install.

Check the console for the error. "t2dsceneGraph::addToScene() - object '' is already in a SceneGraph!"

With a little bit of scripting, you can from here determine that the onRemoveFromScene event is being fired for each of these objects - I can't be sure, but I think the two issues is related.
#2
09/18/2008 (2:16 pm)
I've run into this as well. Looking into the source code, it appears that cloneWithBehaviors is adding the object to the scenegraph twice, in order to trigger onAddToScene callbacks in behaviors. Hopefully this will be fixed in the next version, but until then, you can use this to disable the warning messages:

$pref::T2D::warnSceneOccupancy = false;