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?