hi. i create this js code:
#pragma strict
function Start () {
}
function Update ()
{
if(Input.GetButtonDown(“Fire1”))
{
Punch();
}
}
function Punch ()
{
var ray: Ray=Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if( Physics.Raycast(ray,hit,500))
{
if( hit.collider.gameObject.layer == 8)
{
Debug.Log(“Hit”);
}
}
}
and show this error :
NullReferenceException
UnityEngine.Camera.ScreenPointToRay (Vector3 position) (at C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/ExportGenerated/Editor/UnityEngineCamera.cs:379)
FireScript.Punch () (at Assets/Script/FireScript.js:17)
FireScript.Update () (at Assets/Script/FireScript.js:11)
what this error???
help me help me help me !!! Pleaseeeeeeeeeeeeeeeeeeeeeeeeeeeeee