Referencing instance of game object hit via RaycastHit

How do you reference an instance of a GameObject "hit" via RaycastHit?

I would assume it's this `instanceHit = hit.transform.gameObject` - where instanceHit is a global GameObject variable - but I get this error: NullReferenceException: Object reference not set to an instance of an object

Is your raycast actually hitting a collider/rigidbody? Else the nullreference would be obvious ;) if you're unsure how to test this just use if(physics.Raycast(etc)) which returns true if it hits something and false if it does not.

If you're sure that's not it, alternatively try using hit.collider.gameObject, which I have used successfully in the past. This wouldn't explain why hit.transform.gameObject does not work, though.