How do you reference an instance of a GameObject "hit" via RaycastHit?
I would assume it's this
asked May 07 '11 at 04:08 AM
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.
answered May 07 '11 at 04:15 AM