Hi, I've written some code which disables a script and starts a coroutine when a collision happens, but I get these two errors
**Assets/Scripts/SceneDelay.cs(16,40): error CS1525: Unexpected symbol ), expecting (, [, or {**
and
**Assets/Scripts/SceneDelay.cs(22,4): error CS1525: Unexpected symbol `IEnumerator'**
here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class SceneDelay : MonoBehaviour {
public static int score = 0;
public Text scoreText;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "Obstacle")
{
GetComponent(new ScoreScript).enabled = false;
StartCoroutine(DelayLoad());
}
}
IEnumerator DelayLoad()
{
yield return new WaitForSeconds(1);
SceneManager.LoadScene("Menu");
scoreText.text = 0.ToString();
score = 0;
yield break;
}
}
Both the score script and scene delay script are attached to the same object.
↧