Error Message

an object reference is required to access non static member error. I’m quite new to unity and c# so I’m sure I’m just not referencing it properly or something but can someone please tell me what I’m doing wrong? I’m trying to add force to a rigidbody.

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {
	public GameObject player;
	private static Rigidbody2D rb2d;
	public int speed;
	void Start () 
	{
		Rigidbody2D rb2d = gameObject.GetComponent<Rigidbody2D>();
		speed = 0;
		player = this.gameObject;
	}
	void Update()
	{
		float moveHorizontal = Input.GetAxis ("Horizontal");
		float moveVertical = Input.GetAxis ("Vertical");
		Vector2 moveDirection = new Vector2 (moveHorizontal, moveVertical);
	}
	public void AddForce(){
		Rigidbody2D rb2d = Rigidbody2D.AddForce(moveDirection, ForceMode2D.Force);
	}
}

@verzoto that is static by default, I just put that there for my benefit, how do I make it not static if its default static

Hello!

You need to remove static from your Rigidbody2D rb2d variable.
And you don’t need to declare variable type everytime, just declare the type when you create the variable.