IEnumerator not triggering when start coroutine is called

36 views Asked by At

So my code is supposed to print this out into the console after 3.5 seconds, but it never happens for some reason.

I have no idea what to try.

Here's my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class Talking : MonoBehaviour
{
    public TextMeshPro t;
    public Component talk;

    void Start()
    {
        GetComponent<TextMeshPro>().enableWordWrapping = false;
        StartCoroutine("Speech");
    }

    public IEnumerator Speech()
    {
        yield return new WaitForSeconds(3.5f);
        Debug.Log("yay my code works");
    }
}
1

There are 1 answers

1
Koma On

try StartCoroutine(Speech()); and make sure you script is placed on any object