Script Error C# (Instansiating Infront of Player)

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {
public GameObject Wall;
public Vector3 thePosition = transform.TransformPoint(Vector3.forward * 5);

    // Update is called once per frame
    void Update () {
    if ( Input.GetButtonDown ("Build"))
        Instantiate (Wall, thePosition, Wall.transform.rotation);

I get the error Assets/Scenes/NewBehaviourScript.cs(6,30): error CS0236: A field initializer cannot reference the nonstatic field, method, or property `UnityEngine.Component.transform' any clues?

Is this the best way to instantiate infront of player?

Off to sleep now, Ill check back in the morning (Well it is the morning but after I get up ;D)

The error you're getting is because you are trying to access the `transform` of the GameObject before it is finished initializing. I suggest moving that command to inside either `Start()` or `Awake()`

public Vector3 thePosition;

void Start() {
    thePosition = ...

While this will get rid of your compilation error, it won't solve your problem. The code above would save the players position when it starts and never update it. Better thing would be to not have a `public Vector3` for that at all, but something like the following:

void Update() {
    if (Input.GetButtonDown ("Build")) {
        Vector3 wallPosition = gameObject.transform.TransformPoint(Vector3.forward * 5);
        Instantiate(Wall, wallPosition, Wall.transform.rotation);

Sweet dreams