Warm tip: This article is reproduced from serverfault.com, please click

Unity not destroying object

发布于 2021-10-13 20:53:53
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ArrowScript : MonoBehaviour
{
    void OnCollisionEnter2D(Collision2D collision)
    {
        //GameObject effect = Instantiate(hiteffect, transform.position, Quaternion.identity);
        //Destroy(effect, 5f)
        Destroy(gameObject);
    }
}

What is wrong with this I have no idea could it be a problem with visual studios

https://ibb.co/FqLTVB7 https://ibb.co/5F5wKFL

visualstudio

Questioner
Viperthesniper
Viewed
0
Viperthesniper 2021-10-15 06:24:38

OnTriggerEnter2D worked but I had a bug where it said I was still using it it was because the arrow was inside my player that it was summoning from so the prefab was getting instantly destroyed. Thanks for all the help