Game Development Community

You only live twice but I can only mount once.

by Zilla · in Torque X 2D · 06/21/2008 (12:58 pm) · 3 replies

I mounted a particle effect to an object and everything works fine:

T2DSceneObject particleEffect = TorqueObjectDatabase.Instance.FindObject<T2DSceneObject>("StardustParticles");
                        if (particleEffect != null)                        
                            particleEffect.Mount(myObject, "", true);

But the second time, this code is executed to mount this particle effect to another object, TorqueObjectDatabase.Instance.FindObject does not find this T2DSceneObject again and returns null.

What is missing?

#1
06/21/2008 (1:49 pm)
Why is it called a second time - is the particle effect dismounted or is the mounted object deleted? If the mounted object is deleted the particle effect may be deleted along with it. But if you are just dismounting, then wanting to mount again, then this should work just fine. Also, there's nothing wrong with deleting it, you can always make the effect a template object and then clone a new copy of it each time you want to mount it.

John K.
#2
06/22/2008 (8:10 am)
I think john may be right, if you are in fact deleting the first object maybe both get deleted. Have you tried setting owned by mount to false? ie:
particleEffect.Mount(myObject, "", [b]false[/b]);

Will

edit:Fixed spelling
#3
06/22/2008 (12:25 pm)
@John
Quote:If the mounted object is deleted the particle effect may be deleted along with it.
Shame, shame, shame, shame on me! Of course. Now my particle effect is a template and will be cloned each time I mount it (as you suggested). Thank you very much.

@Will
I tried "false" first. Then the object will be deleted but the mounted particle effect will remain in the scene.