Making objects appear and disappear


#1

Hi there, I have a scene with fish swimming around in the space.

I’d like to make some objects (items from the library and also pre-defined text panels) appear in front of them once they are activated. They also stop moving and turn around to face the camera when clicked.

I’m trying to use the set.Opacity function i’ve seen on the forum - however i’m completely unfamiliar with JavaScript so must be using it wrongly - it doesn’t seem to be doing anything.

Here is the blockly set up:
37 pm

Here is the javascript in the block:
const human = Scene.getItem("LWZrEN1ECS"); human.setOpacity(100)


#2

Ah. just spotted my mistake. the opacity should be 1 instead of a 100.


#3

Hi Yvonne, you can also use the “set Opacity” block which you can find in the “Actions” category.

block-set-opacity


#4

How did I miss that block? Thanks for your help and patience!


#5

Is there a way to do the same with text marker and panels. The “set opacity of” seems to have no effect on text objects.


#6

Hi @arivera!

To make a text item invisible, simply set its text to be empty in the set text of text item - block.

Keep in mind that text panels are a combination of a cuboid (the rectangular, white background item) and a text item, while text items are only the item holding the text.

07