So this code is supposed to disable the GameObject that is hiding another image underneath it when the player walks into its box collider (set to trigger). But when I start the game it doesn’t show the GameObject even when I’m not colliding with it. My player has RigidBody2D and box collider 2D and some other scripts
,This is my code, I’m a beginner so that’s probably the cause
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SeeTroughWalls : MonoBehaviour
{
public GameObject currentshowable = null;
public GameObject showable;
bool seeTroughWalls = false;
private void Start()
{
showable.SetActive(true);
}
private void Update()
{
if(currentshowable = showable)
{
showable.SetActive(false);
}
else if(currentshowable = null)
{
showable.SetActive(true);
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if(other.CompareTag("Player"))
{
currentshowable = showable;
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (other.CompareTag("Player"))
{
currentshowable = null;
}
}
}
Basically I’m trying to disable a GameObject that is hiding another image behind it everytime a player walks inside the 2D box collider (set to trigger) that the GameObject has. My pkayer has “Player” tag, rigidbody2D and a box collider