So when I am clicking on the object in the game I get this error...
NullReferenceExceptionm : Object reference not set to an instance of an object JumpDestination.Update () (at Assets/Scripts/JumpDestination.cs.:12)
I don't know what I am doing wrong,how can I fix it? I want to get the position of the hited object.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JumpDestination : MonoBehaviour {
private RaycastHit hit;
public float jumpMaxDistance;
void Update(){
Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out hit, jumpMaxDistance);
if (hit.collider.gameObject.tag == "RichPoint") {
print (hit.collider.transform.position);
}
}
}