Particle Effects Disappearing from Path
by Ryan Dudley · in Torque Game Builder · 07/12/2007 (6:23 pm) · 1 replies
I am having particle effects detach themselves & disappear while following a path.
Here's what I'm doing
When the user clicks I am creating a 4-node path from the click point going through 2 static points, and ending at a varying point on the screen.
1) Create Path [type = catmull, mode = wrap]
2) Add to Scene
3) Add the 4 nodes
Then I create a particle effect (it simply emits a bunch of small bitmaps at a random orientation) & attach it to the path.
1) Create Effect [mode = infinite]
2) Add to Scene
3) Load Effect
4) Play Effect
5) Attach Effect to Path [mode = wrap]
Then I have a callback for onPathFinished() that stops the effect & deletes the path
1) StopEffect [Yes Kill Effect, Yes Wait for Particles]
2) Safe Delete path
What is happening is that sometimes the effect will just disappear mid-path and onPathFinished() is never called.
I am wondering if this is related to a crash I am getting. When I have the 'Debug Guard' enabled, seemingly randomly a 0 will show up in the pre- or post- guard instead of the defined value. It seems to happen on a different chunk of memory every time.
[Edit: code added below]
Here's what I'm doing
When the user clicks I am creating a 4-node path from the click point going through 2 static points, and ending at a varying point on the screen.
1) Create Path [type = catmull, mode = wrap]
2) Add to Scene
3) Add the 4 nodes
Then I create a particle effect (it simply emits a bunch of small bitmaps at a random orientation) & attach it to the path.
1) Create Effect [mode = infinite]
2) Add to Scene
3) Load Effect
4) Play Effect
5) Attach Effect to Path [mode = wrap]
Then I have a callback for onPathFinished() that stops the effect & deletes the path
1) StopEffect [Yes Kill Effect, Yes Wait for Particles]
2) Safe Delete path
What is happening is that sometimes the effect will just disappear mid-path and onPathFinished() is never called.
I am wondering if this is related to a crash I am getting. When I have the 'Debug Guard' enabled, seemingly randomly a 0 will show up in the pre- or post- guard instead of the defined value. It seems to happen on a different chunk of memory every time.
[Edit: code added below]
Torque Owner Ryan Dudley
Default Studio Name
// create effect function createPathedEffect(%startPos, %endPos) { // create the path %path = new t2dPath() { pathType = "CATMULL"; pathModeEnum = "WRAP"; canSaveDynamicFields = "0"; }; // add it to the scene %path.addToScene(myWindow.getSceneGraph()); // add the nodes %path.addNode("3 -32"); %path.addNode(%startPos); %path.addNode(%endPos); %path.addNode("0 0"); // create pathed particle effect %effect = new t2dParticleEffect() { effectMode = "INFINITE"; effectTime = "0"; canSaveDynamicFields = "0"; }; %effect.addToScene(myWindow.getSceneGraph()); %effect.loadEffect("MyEffect.eff"); %effect.playEffect(true); // attach the particle effect to the path %path.attachObject(%effect,300.0,-1,1,2,"WRAP",1,true); } // particle effect finished moving, kill effect & path function t2dPath::onPathFinished(%this,%obj) { %obj.stopEffect(true,true); %this.safeDelete(); }If anyone has any guesses or suggestions, I'm willing to give them a shot!