Projectile question
by Toks · in RTS Starter Kit · 12/25/2007 (3:07 am) · 1 replies
Hey everyone,
I myself am not using the RTSProjectile in my game as mine is only in 2D, but im going to need something similar to simulate attacks on the clients. so i tried making a SimObject with the member fields i need to interpolate its movement and to render it in my custom rendering control. however im having quite some difficulty getting it deleted properly.
Since they are clientside only objects, they remain registered when leaving a game (i can still see the processTick etc. if i put printf's in them). deleting the simobject after the connection has been terminated will cause the game to crash somehow (how does that happen? you should be able to delete this object without being on a server right?).
despite being bugged with this, i decided to manually clean up the "projectiles" when disconnect() (in script) has been called. it calls:
where projectileList is a simset on the client which i added all the projectiles to (not just the visible ones). strangest thing. if i have a few units fire, the projectiles are removed properly (or at least onRemove is called) when they are done (hit the target). so the SimSet shouldnt become any larger when time elapses. however the longer i played the longer the disconnect takes. this deleting takes up to 30 seconds, even though echoing the simtime implies that not even a single millisecond has passed.
also there has to be a neater way to clean this up. digging through the RTS Starter Kit code, i couldnt find exactly how the projectiles are cleaned up. does this have anything to do with being derived from sceneObject?
I myself am not using the RTSProjectile in my game as mine is only in 2D, but im going to need something similar to simulate attacks on the clients. so i tried making a SimObject with the member fields i need to interpolate its movement and to render it in my custom rendering control. however im having quite some difficulty getting it deleted properly.
Since they are clientside only objects, they remain registered when leaving a game (i can still see the processTick etc. if i put printf's in them). deleting the simobject after the connection has been terminated will cause the game to crash somehow (how does that happen? you should be able to delete this object without being on a server right?).
despite being bugged with this, i decided to manually clean up the "projectiles" when disconnect() (in script) has been called. it calls:
void clearFromProjectiles()
{
while(projectileList->size() > 0)
{
BoardProjectile *proj = (BoardProjectile*)projectileList[0][0];
proj->deleteObject();
}
}where projectileList is a simset on the client which i added all the projectiles to (not just the visible ones). strangest thing. if i have a few units fire, the projectiles are removed properly (or at least onRemove is called) when they are done (hit the target). so the SimSet shouldnt become any larger when time elapses. however the longer i played the longer the disconnect takes. this deleting takes up to 30 seconds, even though echoing the simtime implies that not even a single millisecond has passed.
also there has to be a neater way to clean this up. digging through the RTS Starter Kit code, i couldnt find exactly how the projectiles are cleaned up. does this have anything to do with being derived from sceneObject?
Torque 3D Owner Novack
CyberianSoftware
To clean, the kit uses a Simgroup called MissionCleanup. What you could try its just to use the same mechanism utilized from script with the RTSProjectiles (and many others objects as well): at the bottom of the object creation routine add: