Не работает скрипт, при сокаснавении объекта с другим объектом он не исчезает

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Death")
        {
            Destroy(gameObject);
        }
    }

}

Так а почему б не уточнить что именно не работает?

Для начала надо проверить срабатывает ли

например добавив Debug.Log.

Если срабатывает, то смотреть значение other.tag (например тоже через Debug.Log).

Если не срабатывает, то видимо что-то не так с настройками колайдера на объекте.

я поменял скрипт если тут всё правильно написано то проблемы с OnTriggerEnter2D, если он не работает, то что делать?

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Death")
        {
            Debug.Log("Collider!");
        }
    }

Про

я имел в виду сам обработчик события, про условие с тегом ниже написано.

    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("Collider!");
    }

collider работает в консоль пишется Collider!

насчёт коллайдера в самом unity то и на объекте где стоит тег Death и на Enemy стоит box collider is trigger

Так раз пишет, значит срабатывает тригер, и видимо просто что-то не так с тегом.

Debug.Log("Collider! " + other.tag);

так?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyDeath : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if(other.tag == "Death")
        {
            Debug.Log("Collider! " + other.tag);
        }
        
    }
}

private void OnTriggerEnter2D(Collider2D other)
{
    Debug.Log("Collider! " + other.tag);
}

я сначала так и написал но не чего не сработало просто в консоль пишет Collider! и тег с которым коснулся объект

Так а тег правильный пишет? Death?

да.

я поменял тег и теперь вообще не пишет в консоль

вроде правильно

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyDeath : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("Collider! " + other.tag);
    }
}

я тут сделал новый скрипт и наложил его уже на объект который должен дестроить Enemy

но он тоже не работает , может с колайдером что то не то?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyDeath : MonoBehaviour
{
    public GameObject enem;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }

    public void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Enemy")
        {
            Destroy(enem);
        }
    }
}

когда касаюсь Player он исчезает а когда касаюсь Death нет

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            Destroy(gameObject);
        }
        if (other.tag == "Death")
        {
            Destroy(gameObject);
        }
    }

}

Если

и

то может просто с тегом что-то не так? Не та буква или пробел в конце и т.п.

я это сделал щас по другому

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (transform.position.x < -5.19f)
        {
            Destroy(gameObject);
            ScoreText.Score += 1;
        }
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            Destroy(gameObject);
        }
    }

}