简体   繁体   中英

Unity not destroying object

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

视觉工作室

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM