Game Development Community

Hiding TSStatic

by Jules · in Torque 3D Professional · 07/30/2012 (6:15 pm) · 9 replies

Can you hide TSStatic objects? There was talk about this being added... did it make it in 1.2?

I'm trying to run an animation on a door, so that it closes, then StaticShape fades out replacing it with the door that has collision. I have the animation of the door closing and hiding of the StaticShape, but no collision.

#1
07/30/2012 (6:57 pm)
Well, when attempting to help someone else you end up learning something new.

I went in to test this out and found that one of the first test animations I made was a TSStatic object, I assumed prior that TSStatic shapes were just prop only objects, but I was able to set its collision to visible mesh in a physX build. I did not know this.

Anyways back to your question, in the inspector for either TSStatic or StaticShape objects there is a box that you can click called hidden. This can be toggled true or false by means of script as well.
Do you not have collision for the StaticShape object because you have a physX build?
If you have an FPS build you should be able to create a collision box for the model in your 3D modeling software or use TSShapeConstructor scripts to add collision boxes or spheres like the turret does.
http://docs.garagegames.com/torque-3d/official/content/documentation/Scripting/Advanced/TSShapeConstructorSpecification.html
#2
07/30/2012 (7:25 pm)
I think that you can animate collision meshes ... though I've never tried personally, thus use the staticShape collision rather than create a new TsStatic.

Having said that if it's for single-player you might be able to create a TsStatic in script to block the hole, but that won't network, but you might be able to use some sort of custom postApply() call to update across all clients.
#3
07/30/2012 (7:43 pm)
Yesterday, I try to hide TSStatic Object too with setHidden() function. Unfortunately, it's not updating my Game, TSStatic will be updating after I switch back to World Editor.

Now, I use another method. I still don't know the impact on my game, but it work like what I want. I wrap object create (with its position, rotation, etc) on a function, so if I want to call it, I just call the function and delete it with objectname.delete();
#4
07/31/2012 (9:33 am)
@DreamPharaoh - yeah, I know of the toggle in the editor, but it's not exposed to script on TSStatic, on staticShape I can use the startFade(50, 0, true);

@Steve - I'll check out staticShape collision, although I thought that was just for detection. Maybe I could just prevent the player from moving on detecting. As the door is to protect from attack, not just serve a visual purpose.

@Allan - so create the object and delete it. I'll try this, but not sure what the overhead would be on a networked game.
#5
07/31/2012 (10:16 am)
Just tested calling setHidden() on a TSStatic (with polysoup/visible mesh collision enabled) in both 'singleplayer'/local server mode and dedicated, multiplayer mode and it worked perfectly fine. This is using T3D 1.2. I do remember having some issues with it in 1.1 but those appear to be fixed.
#6
07/31/2012 (10:26 am)
I just tested this with a bullet enabled build, and setHidden hides the TSStatic OK but it's collision remains. Doh.
#7
07/31/2012 (10:50 am)
@Guy is there a way to turn collision off for the TSStatic, setCollision ?

@Chris - hidden, what about collision - can you walk through it?

What syntax are you guys using in code or console?
#8
07/31/2012 (11:13 am)
%obj.setHidden(true);
to hide it
%obj.setHidden(false);
to unhide it
#9
07/31/2012 (11:29 am)
Cheers Guy must have been my syntax, it works for me, but using an animated TSStatic DAE object that is DTS cached, and using setHidden(true) hides the object and the collision, so I can walk through it. Setting it to false makes it visible and collision is back. Sweet!