The name does not exist in the current context

Hi guys

I’m new to coding and unity, and i can’t seem to find a solution to this problem by searching the web :frowning:

My code is this:
using UnityEngine;
using System.Collections;

public class Pump : MonoBehaviour {

	// Use this for initialization
	void Start () {
		GameObject wheel = GameObject.Find("Wheel1");
		WheelControl wheelcontrol = wheel.GetComponent<WheelControl>();
		wheelcontrol.wheeltouch=0;
	}
	
	// Update is called once per frame
	void Update () {
		if(wheelcontrol.wheeltouch==1){  // <---- the problem. Neither wheel control or wheel touch exist in the current context
		if (Input.GetKey ("space"))
						rigidbody2D.AddForce(Vector2.up * -10);
	if (Input.GetKeyUp ("space"))
			rigidbody2D.AddForce(Vector2.up * 2000);
		}
	}
}

This is my other code:

using UnityEngine;
using System.Collections;

public class WheelControl : MonoBehaviour {
	public float wheeltouch = 0;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetKey("down"))
		    rigidbody2D.AddTorque(200,0);
			//transform.Rotate(0, 0, 100);}
	}
	void OnCollisionEnter2D(Collision2D collision) {
		if (collision.gameObject.tag == "Finish"){
			wheeltouch=1;
		}

	}
	void OnCollisionExit2D(Collision2D collisionInfo) {
		if (collisionInfo.gameObject.tag == "Finish"){
			wheeltouch=0;
		}
	}
}

Thanks in advance :-)))

Create your variable “wheelcontrol” in first script as global:

 private WheelControl wheelcontrol = null;

 void Start () {
  GameObject wheel = GameObject.Find("Wheel1");
  wheelcontrol = wheel.GetComponent<WheelControl>();
  wheelcontrol.wheeltouch=0;
 }
 //And etc

I hope that it will help you.