Null Reference Exception: object reference is not set to an object. plz guyz help this msg just making me sick. I don't wht is this?? ,Hi everyone..

This is the script:

using unityEngine;
using system.Collections;

public class playerController : Monbehaviour{

private Rigidbody rb;

void start();
{
rb=GetComponent();

void FixedUpdate()
{
float moveHorizontal= Input.Getaxis(“Horizontal”);
float moveVertical= Input.Getaxis (“Vertical”):

Vector3 movement= new vector3 (moveHorizontal,0.0f,moveVertical;)

rb.AddForce(movement);
}
}
,

You rigidbody variable gets not assigned. A NullReferenceException gets throwed when a variable is not initialized (points to null in memory).

Problems with your code:

  1. Class names should start with uppercase letter (convention)
  2. Class should extend MonoBehaviour (case sensitivity)
  3. start() should be Start() (case sensitivity)
  4. The overloaded method GetComponent() doesn’t exist (use generic)
  5. Input.Getaxis(…) should be Input.GetAxis(…) (case sensitivity)
  6. vector3 should be Vector3 (case sensitivity)

Replace you class with the following:

public class PlayerController : MonoBehaviour
{
    private Rigidbody rb;

    // Use this for initialization
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

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

        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

        rb.AddForce(movement);
    }
}