How do I use the GetComponent to access the RigidBody?

I don’t really know about C#sharp. Could I get help?
This is my program. I’m trying to get the user input to control the player.
I cant get the RigidBody component.

using UnityEngine;
using System.Collections;

[System.Serializable]
public class Boundary
{
public float xMin, xMax, zMin, zMax;
}

public class PlayerController : MonoBehaviour
{
public float speed;
public float tilt;
public Boundary boundary;

void FixedUpdate ()
{
    float moveHorizontal = Input.GetAxis ("Horizontal");
    float moveVertical = Input.GetAxis ("Vertical");

    Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    Rigidbody.velocity = movement;
}

}

Have a look at: Unity - Scripting API: GameObject.GetComponent

First you should create a variable of type Rigidbody and in the Awake you set that variable to the actual component, so that you can use that variable to access the rigidbody later.

Example: (not tested!)

using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour {

    private Rigidbody rb;

    void Awake(){
         rb = gameObject.GetComponent<Rigidbody>();
    }
 
    private void Example() {
        rb.velocity = some value;
    }
}

Also have a look at Unity - Scripting API: Rigidbody if you haven’t already. there are other ways to move the object instead of changing the velocity directly.

Hope you found this helpful!

Check Out the below linq it provide’s the information of using get component:link text