I have recently learned coroutines in C# unity and I tried creating a wait function to wait in between codes. It prints both statements at the same time instead of waiting three seconds. Does anyone know a solution to this problem?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Learninghowtoprogram : MonoBehaviour
{
private void Start()
{
print("hello");
wait(3);
print("hello2");
}
IEnumerator waito(float time)
{
yield return new WaitForSeconds(time);
}
void wait(float time)
{
StartCoroutine(waito(time));
}
}
