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

ArgumentException: The Object you want to instantiate is null.

$
0
0
I want to create an auxiliary function for creating a decal. I have this class which is not attached to any Game Object. public class AuxiliaryFunctions : MonoBehaviour { [SerializeField] private GameObject gunHole; private GameObject decal; public void CreateGunDecal(RaycastHit hit) { decal = Instantiate(gunHole, hit.point, Quaternion.LookRotation(hit.normal)); // Avoid z conflict. decal.transform.position += decal.transform.forward * 0.01f; } } I attached a prefab for gunHole via Unity interface. Then I call the CreateGunDecal in another script which is attached to Player. if (hit.collider.tag == "Level") { auxiliary.CreateGunDecal(hit); } After running I got this error trying to Instantiate a decal. > ArgumentException: The Object you want to instantiate is null. I checked other topics of the same error and tried different approaches but could not find out what was wrong in my case.

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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