So i am working on a game. When programing it so you can kill enemies, I started having this error. I don't know why, because the game works just fine, it just gives me an error every time I shoot. I don't know why. Can someone help. Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bulletmovement : MonoBehaviour
{
public GameObject bullet;
public ParticleSystem impact;
public GameObject impactParticle;
public GameObject turret;
// Start is called before the first frame update
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "turret")
{
turretkill(other);
Destroy(other);
}
Instantiate(impactParticle, transform.position, transform.rotation);
Destroy(bullet);
}
void turretkill(Collider other)
{
turretdeathy turretkilling = other.GetComponent();
turretkilling.turretDying = true;
}
}
↧