How do you detect when an object is loaded?
by D Robinson · in Torque Game Engine · 10/15/2007 (1:55 pm) · 4 replies
I've been wondering something for a long time. How do you detect when an object is actually loaded and ready to show in a TGE game? When a mission loads, you have all three stages of the load process happen (Phase 1: Download Datablocks, Phase 2: Download Ghost Objects, Phase 3: Scene Lighting) and then the scene gets shown in your play GUI. BUT, as the scene is shown, you can see all sorts of objects popping into existence as the load finishes! It would also appear (I think...) that some functions (like getWorldBox) won't work on an object until it is fully able to be shown.
So how do you tell if all objects (or a specific object) have/has finished loading? I need to avoid the 'pop in' visually, and get real values from getWorldBox(). I know that I could probably detect the bogus values ("-1000 -1000 -1000 1000 1000 1000") returned from getWorldBox(), but is there a -real- solution?
Thanks for any help anyone may have...
--
David Robinson
Terris-Hill Productions
So how do you tell if all objects (or a specific object) have/has finished loading? I need to avoid the 'pop in' visually, and get real values from getWorldBox(). I know that I could probably detect the bogus values ("-1000 -1000 -1000 1000 1000 1000") returned from getWorldBox(), but is there a -real- solution?
Thanks for any help anyone may have...
--
David Robinson
Terris-Hill Productions
About the author
#2
10/15/2007 (6:45 pm)
Ahhh. I had always wondered what isProperlyAdded() meant, but I have never looked it up. And I didn't realize that onAdd was happening after they 'popped in'. Is there any easy way to hold back the game until every item is 'properly added'?
#3
One possible "smoke and mirrors" technique would be to provide a distraction screen to the player, or something flashy happening when they first enter the game so that the ghosted objects have time to catch up. Alternatively, you could block the initial view distance by spawning them inside a small room or structure, or some similar technique.
10/15/2007 (6:55 pm)
Umm, well, that's pretty much exactly what the current loading sequence does. I think what you are seeing is actually that you probably have a scene that is densely packed with multiple dozens to hundreds of ghosted objects (not ghost always, which is what is delivered as part of the download sequence), and with that many, it will take several dozen network cycles to deliver all of the initial updates.One possible "smoke and mirrors" technique would be to provide a distraction screen to the player, or something flashy happening when they first enter the game so that the ghosted objects have time to catch up. Alternatively, you could block the initial view distance by spawning them inside a small room or structure, or some similar technique.
#4
A greater problem, though, is that sometimes our scenes require some custom setups where objects are placed relative to other objects in the scene. If we try to place them before they are all 'properly added' then we get into a problem and things don't work like we expect them to work.
I'll definitely look into 'ghost always' objects -- with such a dense, small scene we basically want everything existing on the client, anyways...
10/15/2007 (9:52 pm)
I've got a very dense scene with a lot of objects in a small space (30m x 30m, approximately). Currently we've just been blacking out the screen for XX seconds at the start of the game and then fading in, but XX is getting pretty big for some of the scenarios, and we hate using the black screen for so long...A greater problem, though, is that sometimes our scenes require some custom setups where objects are placed relative to other objects in the scene. If we try to place them before they are all 'properly added' then we get into a problem and things don't work like we expect them to work.
I'll definitely look into 'ghost always' objects -- with such a dense, small scene we basically want everything existing on the client, anyways...
Torque 3D Owner Stephen Zepp
In TorqueScript, you also get a callback (to the script) called ::onAdd() which will be called once the object has been added to the simulation.