Question by
RogueSword13 · Jul 13, 2020 at 09:01 AM ·
c#script.programming
Why cant I access the same function twice?
I have an boundary to detect game fail with a collecting system. And find the gameManager run EndGame(). But It only work at the first time. The collecting system works finely, enable and then disable. Bellow are my scripts.
public float delayTime = 3f;
void OnTriggerEnter(Collider other)
{
FindObjectOfType<GameManager>().EndGame();
//Destroy(gameObject);
gameObject.SetActive(false);
Invoke("Respawn",delayTime);
}
void Respawn()
{
gameObject.SetActive(true);
}
And the gameManager
public void EndGame()
{
if (GameHasEnded == false)
{
GameHasEnded = true;
Invoke("ReturnSpawnPoint", RestartDelay);
Debug.Log("Failed");
}
}
public void ReturnSpawnPoint()
{
Marble.transform.position = spawnPoint.position;
Marble.GetComponent<Rigidbody>().velocity = Vector3.zero;
//Debug.Log("Failed");
}
Comment
Your answer
Follow this Question
Related Questions
What is Coroutine, Yiel and IENumerator? 1 Answer
Need help with c# 1 Answer
Game working in pc but not in Android While Testing 0 Answers
Save a Image's state 1 Answer
How can i sort a List ? 1 Answer