line number 9, on the raycast
I gave it test, and the ray casting is giving him problems.
Camera.main.transfom.foward is returning null becuase he spelled forward wrong. lol
here the working code:
var SplashObject : GameObject;
var UseRotation: boolean = false;
function Update () {
if(Input.GetButtonDown("Fire1")){
var hit : RaycastHit;
if (Physics.Raycast(Camera.main.transform.position,Camera.main.transform.forward, hit, 1000)){
var pos : Vector3 = hit.point;
var rot : Quaternion = Quaternion.identity;
if( UseRotation == true)
rot = Quaternion.FromToRotation(Vector3.up, hit.normal);
Instantiate(SplashObject,pos,rot);
}
}
}
null references are the most common errors I’ve ever seen, especially here in Unity.
null references mean your aren’t referencing something or something your referecing is null. best way to fix them is to check what vars are null using if
statements and print(“this var is null”)
also DaveA has a point , you did’t really give enough info which can infuriate people. which is probably he deleted my half written answer lol.