Trying to code a wall.

Hello, I’m attempting to code a wall that disappears once the count reaches a certain number. The problems I’m having are that I’m not sure where to put a code for it to turn off, and I’ve tried Debug.log and even that didn’t work. Any help is greatly appreciated. This below is my whole code on the player that allows it to collect the other pickup items and change the count.

using UnityEngine;
using System.Collections;

using UnityEngine.UI;
using System;

public class PlayerController2 : MonoBehaviour
{

    public float speed;            
    public Text countText;         
    public Text winText;           

    private Rigidbody2D rb2d;      
    private int count;             

   
    void Start()
    {
        rb2d = GetComponent<Rigidbody2D>();

        count = 0;

        winText.text = "";

        SetCountText();

    }

   
    void FixedUpdate(){
       
        float moveHorizontal = Input.GetAxis("Horizontal");

        float moveVertical = Input.GetAxis("Vertical");

        Vector2 movement = new Vector2(moveHorizontal, moveVertical);

        rb2d.AddForce(movement * speed);
    }


    void OnTriggerEnter2D(Collider2D other){

        if (other.gameObject.CompareTag("PickUp")){
            other.gameObject.SetActive(false);
            count = count + 1;
            SetCountText();
       
        }

        else if (other.gameObject.CompareTag("Rocket")){

            other.gameObject.SetActive(false);
            count += -2;
            SetCountText();
       
        }
        if (other.gameObject.CompareTag("Star")){

            other.gameObject.SetActive(false);
            count = count + 3;
            SetCountText();
        }

        if (other.gameObject.CompareTag("Wall")){
            if (count >= 8) {
                other.gameObject.SetActive(false);
            }
        }
    }
       

    void SetCountText()
    {

        countText.text = "Count: " + count.ToString();
        if (count >= 15)
            winText.text = "You beat level 2! Now to the final stage!";
       
        if (count >= 15)
            Invoke("ChangeLevel", 3.5f);
       
        if (count <= -1)
            Invoke("ChangeLevel2", 0f);

    }

     void ChangeLevel()
     {
         Application.LoadLevel("level3");
     }

    void ChangeLevel2()
    {
        Application.LoadLevel("lose");
    }
}

I would think it would go here. does this work or not work?

if (other.gameObject.CompareTag("Wall")){
            if (count >= 8) {
               Debug.Log("turn off wall");
                other.gameObject.SetActive(false);
            }
        }

I tried and it didn’t work. Thank you though. I don’t know what I’m doing wrong.

so if the debug does not print, you need to verify that the collision object has the tag assigned to it.
you can put the debug before the if statement to verify.

and I see that you are using OnTriggerEnter, so you need to make sure the wall object has a collider that is set to be a trigger. it’s just a checkbox that needs to be On

I set it to be a trigger and the code worked, but when I went to test the door before reaching the target count, it ignores the collider

I got it to work, I did set the box collider to “is trigger” and kept going through. So I added another box collider and made it smaller but didnt select “is trigger” so I can no longer pass through it. I tested with a score of 0 and the target score and it worked.

yep, that’s what needs to be done, two colliders!