Converting random 2D movement to 3D

Following
this tutorial on youtube I am trying to convert the random movement from 2D to 3D

my error says

Assets/RandomScript.cs(26,28): error CS0120: An object reference is required to access non-static member “UnityEngine.Rigidbody.AddForce(UnityEngine.vector3, UnityEngine.ForceMode)”

my script is above, the 2D script i am trying to convert is below

75037-script2.png

In your script(RandomScript.cs) you’re trying to use the Type called Rigidbody rather then the helper instance which if you look at the 2d script is lowercase. Change line 26 to use lower case and depending on the version you’re using it will function fine, otherwise you will need to use GetComponent to get the instance of the rigidbody attached to the gameobject. If you’re using the 5 versions you are probably fine as they did add those properties due to how often that component is used in code.

// change to:
rigidbody.AddForce(force * new Vector3(x, y, z));
// Rigidbody is an object type, rigidbody is a variable pointing to a component on that object(or null otherwise) which is the Rigidbody type.