Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

I keep getting a nulreferenceexception: object reference not set to an instance of an object error even though my game works

$
0
0
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; } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>