Lego Microgame Timer Trigger

Hi Community,

I am learning Lego Microgame and have a question about Timer Trigger. I would like to make a cage, when the player touch the Touch Trigger, the cage gate open. After certain seconds, the cage gate will close automatically.

I want to make: Player touch Touch Trigger and use Move action brick to open the gate, after certain seconds (fx. 10 seconds ), use Timer Trigger to trigger another Move action brick to close the gate. How could I active my Timer Trigger after open Move action finished?

Thanks a lot!

Hi 0/, you can use Coroutines to make a timer and starts it in your open cage method, something like this:

using System.Collections;
using UnityEngine;

public class CageTrigger : MonoBehaviour
{
    void OpenCage()
    {
        //Open action, calls by your Touch Trigger
        StartCoroutine(CloseCageTimer(10));//Starting the timer
    }

    void CloseCage()
    {
        //Close action
    }

    IEnumerator CloseCageTimer(float timeToClose)
    {
        yield return new WaitForSeconds(timeToClose);//Wait for the time (10 seconds in my example)
        CloseCage();//closes the cage
    }
}