简体   繁体   English

统一不破坏对象

[英]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 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. OnTriggerEnter2D 工作,但我有一个错误,它说我仍在使用它,这是因为箭头在我的播放器内部,它是从它召唤出来的,所以预制件被立即破坏了。 Thanks for all the help感谢所有的帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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