Hi there,
A new problem has just appeared in my code. In OnTriggerEnter i’m testing if the player collides with the obstacle. When I tell the script to display a message it works fine. But when I replace the Debug.Log("test")
, with: deadScreen.gameObject.SetActive(true)
to enable my death screen, it just dosen’t work and I don’t know why. Any help would be appreciated. Thanks in advance.
⠀⠀
⠀
Here’s my CollisionWithObstacle script that’s attached to my obstacle:⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollisionWithObstacle : MonoBehaviour
{
public GameObject deadScreen;
private bool isShown = false;
public static bool alive = true;
void Start()
{
isShown = false;
}
private void OnTriggerEnter(Collider other)
{
alive = false;
}
private void Update()
{
if (!alive)
{
deadScreen.SetActive(true);
deadScreen.active = true;
isShown = true;
}
}
}