"Invisible" actors

One option I have in my game is for user characters to use “invisibility”. In the game, I would like to represent this by making the actor model look transparent.

Is this something that can be done with code? Is there sample code I can look at? Or so I need to check with 3d artists on this?

There are all sorts of approaches. The easiest is:

model.setAlphaScale(0.5)
model.setTransparency(TransparencyAttrib.MAlpha)

David

thx! that sounds easy enough. I’ll try it out?

Would it be equally easy to make a model “brighter” to indicate it had been selected?

“brighter” is a little harder, because a lot of times your models are already as bright as they can be in the fixed-function rendering model. You can use a shader to desaturate the textures somewhat, or you can apply a glow filter; or you can turn off texturing.

If your model has colors built into it, though–vertex colors or whatever–then you can just use setColor() or setColorScale() to make it brighter. Most models don’t use vertex colors, though.

David

Got this working well on my characters, but can’t seem to get them visible again (it’s a toggle control).

	def invisible(self):
		if self.isInvisible: # visible again
			self.model.setAlphaScale(1.0) 
			#self.model.setTransparency(TransparencyAttrib.MAlpha)
			self.model.setTransparency(TransparencyAttrib.MNone)
		else:
			self.model.setAlphaScale(0.25) 
			self.model.setTransparency(TransparencyAttrib.MAlpha)

Sure I’m not using the right setting to remove the transparency. Can anybody tell me what I should use? thx!

Those options should work, although:

self.model.clearAlphaScale()
self.model.clearTransparency()

is a little more optimal. But it shouldn’t matter much. If it’s not working, perhaps it’s because you haven’t set self.isInvisible or something like that.

David

D’OH (slaps forehead) :slight_smile:

Thx!

(I’ll try the more optimal one)

OK this works fine:

	if self.isInvisible: # visible again
			self.isInvisible = False
			self.model.setTransparency(TransparencyAttrib.MNone,1)
		else:
			self.isInvisible = True
			self.model.setAlphaScale(0.25)
			self.model.setTransparency(TransparencyAttrib.MAlpha)

but not this:

	if self.isInvisible: # visible again
			self.isInvisible = False
			self.model.clearAlphaScale()
			self.model.clearTransparency()
		else:
			self.isInvisible = True
			self.model.setAlphaScale(0.25)
			self.model.setTransparency(TransparencyAttrib.MAlpha)

it tells me:
self.model.clearAlphaScale()
AttributeError: ‘Actor’ object has no attribute ‘clearAlphaScale’

1 last thing on this.
Is there a way to have it fade gradually?

I use self.model.scaleInterval(1.0, 3) elsewhere, is there a transparency equivalent?

It’s colorScaleInterval.

Thx! I’ll give that a try.

BTW, do you know how I would use clearAlphaScale with an Actor (my error from the post above)? thx!

clearAlphaScale never exist.
Maybe he means clearColorScale.