Hi, I small issue that has been annoying me.
So, I have a script that is going to read the UI text and it gives me this error.
And here is my script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Drone_hieght : MonoBehaviour
{
//[System.NonSerialized]
public float height;
public float oldheight;
public int repeats = 100;
public int strength = 1;
public float time = 6;
public float pointb;
public GameObject GameController;
public int int_ui;
public int str_ui
public Text UI_Units;
// Use this for initialization
void Start()
{
height = Random.Range(5.0f, 7.0f);
}
// Update is called once per frame
void Update()
{
transform.position = new Vector3(transform.position.x, height, transform.position.z);
if (height <= 0)
{
//print("yo");
//GameController.GetComponent<Units>().units += 10;
// print(GameController.GetComponent<Units>().units);
Destroy(gameObject);
GameController.GetComponent<Units>().units += 10;
int_ui = int.Parse(UI_Units.text);
str_ui= int_ui - RF_cost;
UI_Units.text = str_ui.ToString();
}
}
void OnCollisionEnter(Collision collision)
{
// if (collision.gameObject.tag == "Floor")
// {
GameController.GetComponent<Units>().units += 10;
print(GameController.GetComponent<Units>().units);
Destroy(gameObject);
// }
// else
// {
Destroy(gameObject);
// }
}
void OnTriggerEnter(Collider col)
{
// if (found == false) {
//cols = cols + 1;
print("Detected collision between " + gameObject.name + " and " + col.GetComponent<Collider>().name);
//print("some col");
if (col.gameObject.tag == "RF")
{
print("SIGNAL");
//founded = col;
//Drone = GameObject.Find(col.transform.parent.gameObject.name).GetComponent<Drone_hieght>();
//print(Drone);
height -= 0.1f;
Down();
}
}
void Down()
{
oldheight = height;
pointb = height - strength / 100;
height = Mathf.Lerp(oldheight, pointb, time);
}
}
Please help and thank you. I am sure I made a very small error somewhere.
