R
R
realmadness2020-03-29 17:33:54
Android
realmadness, 2020-03-29 17:33:54

How to call a method that will turn on and off every few seconds?

Hello, I want to enable and disable the method every few seconds, namely: I want the platforms to be disabled 5 seconds after the game starts. Also, after 5 seconds, these platforms turned on, and so on throughout the level. I did the shutdown of the platform itself, now I need to add to this script the time after which the platforms will become active and inactive. Here is the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class activeplatform : MonoBehaviour
{
    private void Update()
    {
        if (gameObject.CompareTag("deletegr")) gameObject.SetActive(false);
    }
}

I know that this seems to be done through Invoke() , but how exactly, please tell me.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DanielMcRon, 2020-03-29
@realmadness

Kurutin to help you, I will not throw links as it is very easy to find a description on them

G
GavriKos, 2020-03-29
@GavriKos

In addition to the coroutine, you can make a simple timer using Time.deltaTime and Update.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question