CS0176: An error I can't move past with rigidbody raycasting

So I’ve just begun work with raycasting and was ecstatic when I finally got my first Raycast up and running. However in modifying it I have hit a snag. Unity keeps popping this wonderful phrase up and google has yielded no results that were helpful. Here is the error:

Assets/PlayerAttack.cs(18,95): error CS0176: Static member `UnityEngine.Vector3.forward’ cannot be accessed with an instance reference, qualify it with a type name instead

Here is my code:

using UnityEngine;
using System.Collections;

public class PlayerAttack : MonoBehaviour {


	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
		RaycastHit hit;
  		Vector3 fwd = transform.TransformDirection(Vector3.forward);
		if(Input.GetKeyDown(KeyCode.E)){
        	if(Physics.Raycast(Camera.main.transform.position, fwd, out hit, 10)){
				if(hit.collider.tag == "Palmtree"){
					hit.rigidbody.AddForce(Camera.main.transform.position.forward);
				}
			}
		}
	}
}

Anyone have any idea?

The forward vector inside the Vector3 class is static, you access it like Vector3.forward, like you did correctly.

But then you wrote:

hit.rigidbody.AddForce(Camera.main.transform.position.forward);

position is Vector3 instance, right? and you’re trying to access the static member forward from it, that’s why it’s barking that error.

Use either Vector3.forward, unless you meant Camera.main.transform.forward