Game Development Community

Hiding a mount?

by Matt Huston · in Torque Game Builder · 07/09/2006 (12:08 pm) · 6 replies

Much like the tank tutorial, I have a turret mounted to an object. I want to hide this mount occasionally.

I try something such as %this.turret.setVisible(false);

I have also tried... $playerTankTurret = %this.turret ;

later calling
$playerTankTurret.setVisible(false);

Nothing happens, no errors are given.

#1
07/09/2006 (4:14 pm)
I just tried setVisible(false) on a mounted object and it worked. Is it still not working for you?
#2
07/09/2006 (8:44 pm)
Hmm, I looked into this more and it is very wierd...

echo("visible" SPC %this.turret.getVisible());
%this.target.setVisible(false);
echo("visible?" SPC %this.turret.getVisible());

The console says this... when I called the function (without telling it to ever be visible again)

visible 1
visible? 0
visible 1
visible? 0

And just for reference, the mount call was this...

%this.turret.mount(%this, "0 0", 0, false, true, true, true);
#3
07/09/2006 (9:35 pm)
Well I got it working but I had to add it to my level.onUpdateScene(%this) funciton. Previously it was being called from a Mouse function.
#4
07/10/2006 (9:37 am)
Oh, I just realized you had Inherit Attributes set to true on your mount. Change this to false and you should be able to set it visible/invisible whenever you want. Sorry I overlooked this earier.
#5
07/10/2006 (10:41 am)
Yea I noticed that when I did %this.turret.dump(); it gave me an error, and now that I put the inherit attributes to true, it works proper.

Putting this in the onUpdateScene for this particular case should work fine though anyway.
#6
07/10/2006 (8:15 pm)
True, but you should be careful putting stuff in onUpdateScene in general. It's ok to test stuff, but you should really either use a timer or a schedule, otherwise you run the risk of completely battering your framerate.