Rigidbody using gravity

I want to enable gravity for this object, (on line 28) but it says “An object reference is required for the non-static field, method, or property ‘UnityEngine.Rigidbody.useGravity.get’”. Here is the code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pickup_cube : MonoBehaviour {

    public bool holding;

    void OnMouseDown()
    {
        holding = true;
    }

    void OnMouseUp()
    {
        holding = false;
    }

    void Update()
    {
        if(holding == true)
        {
            this.transform.SetParent(Camera.main.transform);
        }
        if(holding == false)
        {
            this.transform.parent = null;
            Rigidbody.useGravity = true;
        }
    }
}

you are trying to access the Rigidbody class, not the rigidbody component on the gameobject. You’ll need to use getcomponent

thank you!

But how can I do that lol

gameObject.GetComponent()

Look into GetComponent:Unity - Scripting API: GameObject.GetComponent

Oh ok, thank you sooo much!