I want to get an event when Visible is set to true or false in timeline

I currently have a video set as the material of an Object. I would like to set the Visible of this object to false, and switch it to true when the timeline reaches a certain number of frames, and play the video.
In my opinion, if you want to achieve this, you need to get the timing of the visible switching as an event.
Based on the above, I would like to know how to get the event by switching to true or false for visible. If you have any other ideas, I would appreciate it if you could let me know.

Best regards.

Sadao Tokuyama
tokuyama@1planet.co.jp
https://1planet.co.jp/

The approach I’d use is to create a marker on the timeline at the point you want the video to appear and start playing.

Then you can create an event handler - a script that runs when the marker is hit, and use that to start playing the video.

Create the marker by right-clicking in the time bar at the top of your timeline. Once created, you can drag it earlier or later in time to suit.

To create the event handler, make sure a script node is selected (it doesn’t matter which script node you put the event handler in, really; you’ve probably already got a script node or two n the project you could use), and then drag the marker from the timeline up into the script window. A pop-up menu will appear: choose “Add an event handler > pass”. This’ll create an event handler function for you, and you can add a line or two of code to start the video. Assuming your video object is called my_video_node, adding these two lines ought to work:

symbol.controllers.MyControllerName.elements.TimelineName.labels.startvideo.on("pass", () => {
    // Runs when pass occurs on the startvideo label
    
    // add these lines:
    symbol.nodes.my_video_node.start();
    symbol.nodes.my_video_node.visible(true);
	
});
2 Likes