2D Array and other Script method access

Hello, been trying to sort out this code for some time and I keep getting the same few errors:

Assets/Standard Assets/Scripts/MY Scripts/GetFacing.cs(158,40): error CS0120: An object reference is required to access non-static member GetFacing.FacingMul' Assets/Standard Assets/Scripts/MY Scripts/GetFacing.cs(158,65): error CS0120: An object reference is required to access non-static member GetFacing.FacingMul’
Assets/Standard Assets/Scripts/MY Scripts/GetFacing.cs(158,89): error CS1502: The best overloaded method match for UnityEngine.Vector3.Vector3(float, float, float)' has some invalid arguments Assets/Standard Assets/Scripts/MY Scripts/GetFacing.cs(158,89): error CS1503: Argument #1’ cannot convert object' expression to type float’

What I have been trying to sort out is after I have worked out (in GetFacing) what way the player is facing, I use the 2D array FacingMul with the int facing, to return the appropriate multipliers rather than use multiple if statements.

This is then used in another Script which spawns a model at a X and Z cord multiplied on what comes from the PosMulFacing via Vector3.scale, the Y is always 0 as I am not changing the height.

Below is the code for the GetFacing script, please note C# only please.

using UnityEngine;
using System.Collections;

public class GetFacing : MonoBehaviour {
	
	
	private float curRot;
	
	private float best = 400;
	
	private int facing = 0;
	
	//0 = x, 1 = z
	//private int[,] FacingMul = new int[2,4];
	
	int[,] FacingMul = new int[2,4];
	/*
	{
		{ 0,-1}, //-Z
		{-1, 0}, //-X
		{ 1, 1}, // Z
		{ 1, 0}  // X
	};
	*/
	
	/*
	{
		{ 0,-1}, //-Z
		{-1, 0}, //-X
		{ 1, 1}, // Z
		{ 1, 0}  // X
	};//Array
	*/
		
	private static float negZ = 180,
					     negX = 270,
					   	 posZ = 360,
						 posX = 90;
	
	private float[] RotValues = new float[4];// = new float[4] {negZ,negX,posZ,posX};
	/*  	
	 * -Z: 180		0
	 * -X: 270		1
	 *  Z: 0/360	2
	 *  X: 90 		3
	 */
	
	
	//do some borderline testing with excel? or processing
	
	
	//-------------------------------------------------------------
	// Use this for initialization
	void Start () {
		
		RotValues[0] = negZ;
		RotValues[1] = negX;
		RotValues[2] = posZ;
		RotValues[3] = posX;
		
		FacingMul[0,0] = 0;	FacingMul[1,0] = -1;
		FacingMul[0,1] = -1;FacingMul[1,1] = 0;
		FacingMul[0,2] = 1;	FacingMul[1,2] = 1;
		FacingMul[0,3] = 1;	FacingMul[1,3] = 0;
		
		/*
		{
		{ 0,-1}, //-Z
		{-1, 0}, //-X
		{ 1, 1}, // Z
		{ 1, 0}  // X
	};//Array
	*/
		
		for( int x=0; x<4; x++){
			for( int y=0; y<2; y++){
				
				//Debug.Log("FacingMul["+x+"]["+y+"] = "+FacingMul[x][y]);
				
			}
		}
		
		
		float  curRot = transform.eulerAngles.y;
		
		
		if( curRot < 180 ){
			posZ = 0;
		}else
		if( 180 < curRot ){
			posZ = 360;
		}
		
		
	
	}//Start
	
	
	//-------------------------------------------------------------
	// Update is called once per frame
	void Update () {
		
		best = 400;
		
		float  curRot = transform.eulerAngles.y;//Get Rot
		
		//int facing = 0;
	
		for(int c=0; c<4; c++){
			
			float disToRot = Mathf.Abs(		Mathf.DeltaAngle( curRot, RotValues
 )	);
    			
    			//Debug.Log("c: "+c+", best prior: "+best);
    			
    			if( disToRot < best ){
    				
    				best = disToRot;
    				
    				//test code
    				facing = c;
    			}//if
    			
    			//need to check for new best
    			
    			//Debug.Log ("c: "+c+", best after: "+best);
    			//Debug.Log ("Dis between ("+curRot+"-"+RotValues[c]+" = "+Mathf.DeltaAngle( curRot, RotValues[c] )+")" );
    			
    		}//for
    		
    		
    		
    		
    		
    		if(facing == 0){
    			Debug.Log("facing: -Z");
    		}else
    		if(facing == 1){
    			Debug.Log("facing: -X");
    		}else
    		if(facing == 2){
    			Debug.Log("facing:  Z");
    		}else
    		if(facing == 3){
    			Debug.Log("facing:  X");
    		}else{
    			Debug.Log("facing errored");
    		}//if direction
    		
    		
    	
    	}//Update
    	
    	
    	//---------------------------------------------------
    	//Return Vec3 as returning for a position
    	public static Vector3 PosMulFacing(){
    		
    		return(   new Vector3( FacingMul[0,facing] ,0f, FacingMul[1,facing] )	);
    			
    	}//PosMulFacing
    	
    }//CLASS
    

The following code and script works fine, but this is the only bit that interacts with the above Script.
If I am trying to access the other scripts method wrong, please shout.

    pos = Vector3.Scale( _GetFacing.PosMulFacing(), new Vector3(10,10,10)	);
    				
    			switch(index){
    			case 0:
    				Instantiate(room1, pos,  Quaternion.identity);

Thanks, I am going to continue to try and work this out.

You are trying to access FacingMul, which is a member of the class GetFacing, but you are trying to access it from a static context, namely the PosMulFacing() function. You cannot do this. You can solve this in a couple of ways:

  1. Do not make PosMulFacing() static and require an instance of GetFacing to call that function.
  2. Create a singleton instance (controversial, yes) of GetFacing so that you can access the FacingMul array from within the static function. Something like:

public static GetFacing instance = null;

and then in the Awake() function, have something like:

instance = this;

And then in your static PosMulFacing() you could do GetFacing.instance.FacingMul

Hope this helps.