Monday, April 16, 2012

[FA] Trash whats it do and how to use it.

Hi,
Ok,
im creating some effects on some projectiles.. however it seems that these effects are not being destroyed completely.. or are still using something the game has a limited number of (not sure what BUT something)
anyway here are how i create the emiiters.. and destroy them.. i would have thought that the emmiters are cleaned up when the projectile is destroyed.. this doesnt seem to be the case.. im prolly missing something stupid..
http://pastebin.com/jAy9rJTv
ok just to be clear.. the projectiles are created and seem to be destroyed, they vanish when the destroy funciton is run.. however something is being left behind.. because after a few thousand of these effects have been created and removed..
i get errors in my log when ever another effect is created from scratch..
i currently disabled the creation of the effects above on the projectiles and the error has dissappeared... so defo something is left behind when i create and destroy these effects..
what i thought is that the trashbag might be what i need here to make sure everything is removed when the projectile dies.. or i remove the effect manually..
so how do i use "a trashbag" and will it help this problem?
if you see another problem please let me know :)|||Objects in a trashbag are destroyed when the owner of the trashbag is destroyed, so if you want emitters to last as long as the projectile, then stick them in the projectile's trashbag.|||Why not just copy one of the methods that GPG's units use to handle effects? There are plenty of specific examples of complex emitter effects with proper trashbag handling.
Which object's script is this in? The unit's, or the projectile's?|||Hi,
The projectiles,
what ive done is create a TrashBag() if not self.Trash
upon creating an effect in local i then add this effect to a table...
at the end of the function i loop the table and do self.Trash:Add(v)
hopefully this correct.. and the effects that are destroyable are completely destroyed..
when the projectile dies :)|||Why not just add them straight to the TrashBag?|||TrashBags have to be disposed of. If you create one yourself, you'll have to manually tell it to clear. Adding to an existing bag (ala. a bag that GPG made) should work off the bat.|||BulletMagnet|||Al projectiles already have a trashbag, self.Trash. Everything is handled automatically (on the projectile's destruction) if you just add emitters to that.

No comments:

Post a Comment