Lifetime of SimObjects in the engine
by Igor G · in Torque Game Engine · 07/25/2007 (12:00 pm) · 3 replies
I am trying to create an object (SimSet to be precise) and save it in a global array. Then another function tries to access this object later and says the object is nowhere to be found. I'm a little confused about the lifetime of these objects. I thought they get deleted when you tell them to, so I don't understand why the object is no longer found.
I've tried to create the SimSet in C++ code and in Torque code, both methods don't work. The object that was stored in my global array was unable to be found shortly after. I'm assuming it was deleted. Can anybody help me understand what's going on?
Thanks.
I've tried to create the SimSet in C++ code and in Torque code, both methods don't work. The object that was stored in my global array was unable to be found shortly after. I'm assuming it was deleted. Can anybody help me understand what's going on?
Thanks.
#2
Maybe your global reference is screwed. Test it by doing:
and when you test it from your global array also just test $test.
07/25/2007 (12:05 pm)
Igor, the SimSet should be persisted until you either delete it or Torque exits.Maybe your global reference is screwed. Test it by doing:
$test = new SimSet() { ...and when you test it from your global array also just test $test.
#3
07/25/2007 (12:21 pm)
Whoops, I seem to have fixed my problem now. I was actually refactoring my code and didn't notice that one of the callers was deleting the SimSet. So that's fixed now, but it's still good to know that objects live as long as they don't get deleted by me.
Torque 3D Owner Stephen Zepp
--you create the object on the server, and are trying to access on the client, without ghosting (and properly referencing) the object
--you didn't properly create the object, and/or register it (if registration of an object fails, it is removed from the simulation)
--you are not accurately storing and/or retrieving the object handle from your global array.
Without examples of what you are doing (TorqueScript), we can't help much more other than suggest possible directions (which are all pretty much guesses).