Ghost Projectiles
by Liu Yi · in Torque Game Engine · 02/26/2007 (7:51 am) · 4 replies
In my game, I create a series of projectiles one after another from a point. Each time a projectile is created, it is added to a SimGroup called "projectiles". However, after the game running for a while, I find there are some projectiles that are not in the "projectiles" SimGroup.
These projectiles are not even visible, but it is in the game world, because I added a line in the processTick function in projectile.cc:
Con::printf("projectile: %d", this->getId());
Therefore, when i run the game, the ID of each projectile in the game world are printed in the console. I found that some of the ID are not in the "projectiles" SimGroup.
Can anyone explain to me where these ghost projectiles are from? Thanks.
These projectiles are not even visible, but it is in the game world, because I added a line in the processTick function in projectile.cc:
Con::printf("projectile: %d", this->getId());
Therefore, when i run the game, the ID of each projectile in the game world are printed in the console. I found that some of the ID are not in the "projectiles" SimGroup.
Can anyone explain to me where these ghost projectiles are from? Thanks.
#2
If you add an object to a SimGroup that was already in a different SimGroup, it is removed from the first one. Very often, if you put your projectile into a SimGroup, and then put it in, for example, the MissionCleanup SimGroup, it is removed from yours.
In general, you shouldn't use SimGroups unless you specifically want this property.
02/26/2007 (9:20 am)
In addition, SimGroup is a very special class, where an object can only be in one SimGroup at a time.If you add an object to a SimGroup that was already in a different SimGroup, it is removed from the first one. Very often, if you put your projectile into a SimGroup, and then put it in, for example, the MissionCleanup SimGroup, it is removed from yours.
In general, you shouldn't use SimGroups unless you specifically want this property.
#3
How about SimSet? Can an object be in more than one SimSet at the same time? And can an object be in one SimSet and also one SimGroup?
For example if I put an object in a SimSet that I created, can I also add this object to the MissionCleanup SimGroup?
Thanks.
02/26/2007 (9:14 pm)
Thanks for the advice Stephen Zepp.How about SimSet? Can an object be in more than one SimSet at the same time? And can an object be in one SimSet and also one SimGroup?
For example if I put an object in a SimSet that I created, can I also add this object to the MissionCleanup SimGroup?
Thanks.
#4
02/26/2007 (11:39 pm)
Yes, and yes. That's how they are designed :)
Torque Owner Sam Redfern