Rigid body can't find the instance

Hi i’m getting baffled by a “NullReferenceException: Object reference not set to an instance of an object”.
in my code for the player i have

    //for handling of player
    protected Rigidbody rb;
    protected Collider col;

    // Start is called before the first frame update
    void Start()
        //getting live object data
        rb = GetComponent<Rigidbody>();
        col = GetComponent<Collider>();

        if (rb = null)
            Debug.Log("player's rigidbody is null");
        if (col = null)
            Debug.Log("player's Collider is null");
        //rigidbody test for example
        rb.velocity = new Vector3(0,0,1);

i get the Null referance on :

        rb.velocity = new Vector3(0,0,1);

Double check everything i can think of. Script is attached to game object and the rigidbody is on that same game object. the null checks are not coming up in the Debug log.

So I’ve hit a block and have come for some help

if (rb = null)…

You are assigning it null in the if statement.

It needs to be If (rb == null). :slight_smile:

My mistake as soon as i postyed it i got it figured.
my conditional statements like:

         if (rb = null)

are using assignment operators in tead of ‘==’

been spending to much time in excell and vba