public Rigidbody CursorRigidbody () {
RaycastHit hit3;
Vector3 origin = Camera.main.transform.position; //Starting point of the ray
Vector3 direction = Camera.main.transform.forward; //Direction of the ray
if (Physics.Raycast (origin, direction, out hit3)) { //If the ray hit something
if (hit3.rigidbody != null) { //If the hit ahs a rigidbody
return hit3.rigidbody; //Return the rigidbody
} else
return ???; //What to put here
} else
return ???; //What to put here?
}
return null, then before using the returned value make sure it’s not null.