Answer the question
In order to leave comments, you need to log in
NullReferenceException: Object reference not set to an instance of an object how to solve?
NullReferenceException: Object reference not set to an instance of an object How to solve?
I copied the entire script from the unity documentation
https://docs.unity3d.com/ru/530/ScriptReference/In...
Script:
public GameObject Ammo;
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray))
Instantiate(Ammo, transform.position, transform.rotation);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question