1
resposta

[Bug] gameObject

he 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.

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

public class BalaEnbora : MonoBehaviour
{
    public float Velocidade = 20;


    void  FixedUpdate()
    {
        GetComponent<Rigidbody>().MovePosition
    (GetComponent<Rigidbody>().position +
    transform.forward * Velocidade * Time.deltaTime);
    }
    void OnTriggerEnter(Collider objetoDeColisao)
    {
        if(objetoDeColisao.tag == "Inimigo")
        {
            Destroy(objetoDeColisao.gameObject);
        }

    Destroy(gameObject);
}
}

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

public class ControlaArma : MonoBehaviour
{ 
    public GameObject Bala;
    public GameObject CanoDaArma;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if(Input.GetButtonDown("Fire1"))
        {
            Instantiate(Bala, CanoDaArma.transform.position, CanoDaArma.transform.rotation);
        }

    }
}
1 resposta

Oi, Nicolas, pode colar todos os erros aqui? normalmente os erros falam a linha do script certinho pra gente poder filtrar