Possible to Tap Button to Record Video instead of Holding Button?

ZachShirikjian
ZachShirikjian Posts: 2
edited July 2022 in General #1

Hello,

I am currently working on a Lens Studio game. I want to implement a feature where when the user taps the Start button, the lens automatically starts recording. Is it possible to start recording the Lens when tapping a Button, instead of having to hold down the button? If so, could you provide an example of how to do it via Scripting?

Thank You,
Zach

Answers

  • Bakari Mustafa
    Bakari Mustafa Posts: 178 🔥🔥🔥

    Hi Zach,

    it is possible to start recording a lens when tapping a button, instead of having to hold down the button. To do this, you can use the Record component and the Button component, and write a script to start the recording when the button is tapped.

    Here is an example of how you can start recording a lens when tapping a button using scripting:

    1. Add a Record component to your scene: Drag a Record component from the Object Library onto the root object of your scene.
    2. Add a Button component to your scene: Drag a Button component from the Object Library onto the root object of your scene.
    3. Write a script to start the recording when the button is tapped: In the script, use the "onButtonDown" event of the Button component to start the recording when the button is tapped. Here is an example of how you could do this:
    // Import the Record component
    const Record = require('Record');
    
    // Get a reference to the Record component
    const record = script.getSceneObject().getComponent(Record);
    
    // Handle the onButtonDown event of the Button component
    script.button.onButtonDown = function() {
      // Start the recording
      record.startRecording();
    }