TryGetComponent function:

Where were you getting a null reference? If the Raycast hits something then raycastHit.transform should always be set

1 Like