Convert (Typecast) Rigidbody to GameObject

Unity 5.1.2f

I have Scene with Main Camera, object with rigidbody component and empty game object.
Main Camera has a script attached to it. In public references to Game Object and Rigidbody are getted by drag-and-drop from Hierarchy View to Inspector.

No matter how i try to cast Rigidbody to GameObject I’ve got error whenever it’s as-cast, c-cast or imlicit conversion.

    public Rigidbody rocket;
	public GameObject gameObject;

	void Start()
	{
		if(rocket != null && gameObject != null)
		gameObject = rocket;
	}

error CS0029: Cannot implicitly convert type UnityEngine.Rigidbody' to UnityEngine.GameObject’

If I try as-cast or c-cast I’ve got other errors.
error CS0039: Cannot convert type UnityEngine.Rigidbody' to UnityEngine.GameObject’ via a built-in conversion
error CS0030: Cannot convert type UnityEngine.Rigidbody' to UnityEngine.GameObject’

What’s the matter??

A Rigidbody is not a GameObject so you cannot cast to it.

If you want to access the game object that a component is attached to then you can use the gameObject property that exists on every component.

GameObject go = rocket.gameObject;

Or if you want to assign a component that is attached to a gameobject…

Rigidbody rocket = gameObject.GetComponent<Rigidbody>();

The Unity editor does some of these things behind the scenes when you for example drag a gameobject to a property that wants a component.

What are you trying to do exactly?

Thank you, Dave for your wide answer! Now it’s clear to me.