I'm having trouble finding out how to share variables between different c# files. I'm relatively new to coding in this language and i don't know how to access a Boolean from one file in another.
I can provide code if needed, i'm using unity if that matters. I'm being told that the variable doesn't exist in current context. ask if more info is needed i don't really know what you nee to answer this.
this is the first file
using System.Collections; using System.Collections.Generic; using UnityEngine; public class floorAndWallCheck : MonoBehaviour { public bool isGrounded = false; public void OnTriggerEnter2D(Collider2D floor){ if (floor.tag == "floor") { isGrounded = true; }else { isGrounded = false; } } } this is some lines from second file
void Update () { //left if (Input.GetKey("a")) { player1.transform.Translate(Vector3.left * Time.deltaTime * speed); } //right if (Input.GetKey("d")) { player1.transform.Translate(Vector3.right * Time.deltaTime * speed); } //up if (Input.GetKey("w") && isGrounded == true) { player1.transform.Translate(Vector3.up * Time.deltaTime * jumpForce); }