Help for this (Coroutine couldn't be started because the the game object is inactive!)

public void Start()
    {
        gameObject.SetActive(true);
    }
    public void StartToRotate()
    {
        StartCoroutine(Rotate());
    }

    public IEnumerator Rotate()
    {
        while (true)
        {
            yield return new WaitForSeconds(1);
            transform.Rotate(Vector3.one, RotationSpeed * Time.deltaTime, Space.World);
        }
    }

Coroutine couldn’t be started because the the game object ‘BluCapsule’ is inactive!
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
Goto:StartToRotate() (at Assets/Goto.cs:15)
AuctionManager:Auction() (at Assets/AuctionManager.cs:76)
d__22:MoveNext() (at Assets/AuctionManager.cs:52)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Well, the gameobject the script is on isn’t active. So the coroutine can’t start.

2 Likes

Start() won’t run unless the object is already active, so writing gameObject.SetActive(true); inside of Start() is useless.

3 Likes