The prefab is a hazard, and when the ball collides with the trigger, it triggers the game over panel.
However, only the last prefab dragged into the hierarchy does this correctly, not all of them.
The prefab has the ‘GameOver’ script attatched:
public void OnTriggerEnter(Collider collider)
{
if (collider.tag == "Player")
{
//gameOver
gameOver = true;
//disable mesh
collider.gameObject.GetComponent<MeshRenderer>().enabled = false;
//freeze pos
PlayerController.instance.playerRb.constraints = RigidbodyConstraints.FreezeAll;
//disable move buttons
foreach (GameObject buttons in MoveButtons)
{
buttons.SetActive(false);
}
//instantiate explosion
Instantiate(playerExplosion, collider.transform.position, Quaternion.identity);
}
}
}
And the GameManager has the following:
public void Update ()
{
isGameOver = GameOver.instance.gameOver;
//check for game over
if (isGameOver)
{
gameOverPanel.SetActive(true);
}
}
Why does this only work for the last placed prefab ? any thoughts ?
Here is a video of the problem -
Thank you.