My Game Over Canvas is working in one level but not the other!
This is undoubtedly the weirdest bug I have ever had. Currently, I have some code which checks if my character collides with water (which the character hates) and it displays a 'game over' canvas if positive:
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Water"))
{
Debug.Log("Fail");
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
canMove = 0; //stops movement of character
CameraScript.sounds.Stop(); //stops level background music
failCanvas.SetActive(true);
if(failCanvas.activeSelf)
{
Debug.Log("Should work");
}
sounds[0].Play(); //plays sad music
}
By the way, this script is on my player character so if you're wondering, the script always remains active! Here is the weird thing: This worked absolutely fine for level 1, the player fell and it would say 'game over!' when I finished making level 2, the game over canvas didn't come up! However, and this is the weird part: The debug log came up with 'Fail', therefore my character did collide with the water. And it also came up with 'Should work'. That means that failCanvas is active, but the components aren't showing. It's all fine in level 1, but not in level 2!!! This is really inconvenient. Please help!