Trouble with null object reference.

I’ve been trying to get some red paint to fire from a gun in a 2D, side-scrolling game, but I’ve been having trouble with the actual movement of the paint. As soon as I instantiate the paint at the guns barrel, it sits still despite my AddForce behavior, and apparently it’s due to the FirePaint() method having its argument “GameObject p” (which will be used later in the game to detect which color of paint is equipped) it throws this error:

Object reference not set to an instance of an object
PaintFiring.FirePaint (UnityEngine.GameObject p) (at Assets/Scripts/PaintFiring.cs:27)
PaintFiring.Update () (at Assets/Scripts/PaintFiring.cs:20)

Here’s my code:

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

public class PaintFiring : MonoBehaviour {

	public GameObject redPaint;
	public Transform barrelEnd;
	public int paintSpeed = 5;

	void Start()
	{
		redPaint = GameObject.Find ("RedPaint");
	}

	void Update()
	{
		if(Input.GetKeyDown(KeyCode.Space)) 
		{
			FirePaint(redPaint);
		}
	}
	void FirePaint(GameObject p)
	{
		Rigidbody2D paintClone;
		paintClone = Instantiate(redPaint, barrelEnd.position, barrelEnd.rotation)as Rigidbody2D;
		paintClone.rigidbody2D.AddForce(new Vector2(paintSpeed, 0));
	}
}	

I have no idea why this would throw the exception it did. I’m passing a parameter GameObject in the Update method, which is what Unity says I’m not passing. I’m probably missing something basic, so please excuse me in that regard. I’m still new to C#, and i’m not completely up to date on the differences between UnityScript and C#. I have used it outside of Unity, but I don’t know how to use it in Unity very well yet…

You defined redPaint as a GameObject but you’re attempting to instantiate it as a Rigidbody2D. You can’t cast a GameObject to a Rigidbody2D so it’s just null.

//Put this into your code to see if this is where you messed up
//Spelling and caps matter, always make sure you have found a object after looking, unity will
// not through an error if it can not find the object it just returns null

 void Start()
    {
        redPaint = GameObject.Find ("RedPaint");
        //Look to see if we have found the gameobject
        if (redPaint == null){
            Debug.LogError("Can not find RedPaint");
        }
    }