There is a float value in my scriptA. And, I'd like to access this float value and change it in scriptB. But, I am getting message that " static member ScripA.float cannot be accessed with instance reference, qualify with type instead. "
My Script A:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Rectangel : MonoBehaviour { public static float speed = 2; void Start () { } // Update is called once per frame void Update () { } } My script 2:
public class script2 : Monobehaviour { public Rectangel rectangle; void Start () { rectangle = GetComponent <Rectangel> (); } void onCollisionEnter2D (Collision2D col) { if (col.gameobject.tag == "Whatever"){ rectangle.speed = 3f; } } }