Добрый вечер! Скажите, где в коде пули:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
public float speed = 100f;
public Rigidbody2D rb;
public GameObject bullet;
// Start is called before the first frame update
void Start()
{
rb.velocity = transform.right*speed;
}
void OnTriggerEnter2D(Collider2D collider)
{
if(collider.gameObject.name != "Player")
{
Destroy(gameObject);
}
}
Что-то сделано неправильно? При запуске игры выдаёт ошибку:
The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
В уроках в интернете такой-же код.