The name `gameObject' does not exist...? Yes i did my research.

TTA_Coord.cs(12,15): error CS0103: The name `gameObject’ does not exist in the current context

Please help me make this disappear. I have looked this up and have not been able to apply the solutions to my code sucessfully. I am working on a unique project and I need a script attached to a sprite that references a non Mono behaviour scripts “X Y and Z” integers. Here is the script (walker) thats supposed to do the referencing.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Walker : MonoBehaviour {

    //Storing the reference to RagePixelSprite -component
    private IRagePixel ragePixel;
	 
    //enum for character state
    public enum WalkingState {Standing=0, WalkRight, WalkLeft};
    public WalkingState state = WalkingState.Standing;

		
    //walking speed (pixels per second)

	
	 GameObject coordPosit;

	

	void Start () {
        ragePixel = GetComponent<RagePixelSprite>();
	 coordPosit= GameObject.Find("TTA_Coord").GetComponent<TTA_Coord> ();

	}

	


	
	
	
	
	void Update () {
TTA_Coord coordPos = coordPosit.GetComponent<TTA_Coord>();
        //Check the keyboard state and set the character state accordingly
        if (coordPos.x == 5 && coordPos.y == 5 && coordPos.z == 0)
        {
            state = WalkingState.WalkLeft;
        }
        else if (coordPos.x == 5 && coordPos.y == 6 && coordPos.z == 0)
        {
            state = WalkingState.WalkRight;
        }
        else
        {
            state = WalkingState.Standing;
        }

        
        switch (state)
        {
            case(WalkingState.Standing):
				ragePixel.SetSprite("Dripper", 0);
                //Reset the horizontal flip for clarity
                ragePixel.SetHorizontalFlip(false);
                ragePixel.PlayNamedAnimation("drip", false);
                break;
			
            case (WalkingState.WalkLeft):
				ragePixel.SetSprite("Dripper", 0);
                //Flip horizontally. Our animation is drawn to walk right.
                ragePixel.SetHorizontalFlip(true);
                //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts.
                ragePixel.PlayNamedAnimation("drip", false);
                //Move direction. X grows right so left is -1.
                
                break;

            case (WalkingState.WalkRight):
				ragePixel.SetSprite("Barred", 0);
                //Not flipping horizontally. Our animation is drawn to walk right.
                ragePixel.SetHorizontalFlip(false);
                //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts.
                ragePixel.PlayNamedAnimation("there", false);
                //Move direction. X grows right so left is +1.
                
                break;
        }

        //Move the sprite into moveDirection at walkingSpeed pixels/sec
        
	}
}

And here’s the script (TTA_Coord) thats supposed to be referenced…

using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;


public class TTA_Coord 
{
	
		void Start () {

	fbs = gameObject.AddComponent<Walker>();


	}

	

 public Walker fbs;
	
	
	
	public int x = 0;
	public int y = 0;
	public int z = 0;
	
	public override string ToString ()
	{
		return x + "," + y + "," + z;
	}
	
	public TTA_Coord(){}
	
	public TTA_Coord(int x, int y, int z){
		this.x = x;
		this.y = y;
		this.z = z;
	}
	
	public bool IsValid(){
		return (this.x >= 0 && this.y >= 0 && this.z >= 0);
	}
	
	public TTA_Coord(TTA_Coord source, TTA_CommandType command){
		
		if(source == null){
			return;
		}
		
		this.x = source.x;
		this.y = source.y;
		this.z = source.z;
		
		switch(command){
			
			case TTA_CommandType.North:{
				this.y -= 1;
				break;
			}
			case TTA_CommandType.South:{
				this.y += 1;
				break;
			}
			case TTA_CommandType.East:{
				this.x +=1;
				break;
			}
			case TTA_CommandType.West:{
				this.x -=1;
				break;
			}
			case TTA_CommandType.Up:{
				this.z += 1;
				break;
			}
			case TTA_CommandType.Down:{
				this.z -=1;
				break;
			}
			
		}
	}
	
	public TTA_Coord(TTA_Coord source){
		
		if(source == null){
			return;
		}
		
		this.x = source.x;
		this.y = source.y;
		this.z = source.z;
	}
	
	public override bool Equals (object obj)
	{		
		if(!(obj is TTA_Coord)){
			
			return false;
		}
				
		TTA_Coord comp = (TTA_Coord)obj;
		
		if(comp.x == x &&
			comp.y == y &&
			comp.z == z){
			
			return true;
			
		}
		
		return false;
	}
	
	public override int GetHashCode ()
	{
		return x + (10*y) + (100*z);
		
	}
	
}

Any help would be gladly appreciated. Thanks bunches. --TheIronHobo

TTA_Coord doesn’t inherit from MonoBehavior so it doesn’t have a gameObject reference. Or a automatic call to Start() by the way. If you want to reference the gameObject from TTA_Coord you have to pass the instance in, maybe in the constructor.