Question by
JGuilhermeFGomes · May 24, 2017 at 08:06 PM ·
gameobjectpositionreference-other-object
CS0120 - Object reference required but it's already assigned.
New to Unity here. I'm having some issues with a script.
I'm trying to find the x,y and z coordinates of a GameObject and logging them. I have this script for that:
public GameObject mrh;
// Use this for initialization
void Start () {
Debug.Log(mrh.transform.position.x.ToString());
_header = new[] {
"TimeStamp",
"BoxCount",
"Right Hand x",
"Right Hand y",
"Right Hand z"
};
}
public static void UpdateData()
{
_data[2] = mrh.transform.position.x.ToString ();
(I erased the parts that don't matter).
Here's the thing. I wrote a different script that also needs GameObjects
public class ShowEndPanel : MonoBehaviour {
public GameObject SimulationPanel;
public GameObject EndPanel;
private double auxTime;
public Text nameText;
public Text scoreText;
// Use this for initialization
void Start () {
EndPanel.SetActive (false);
}
// Update is called once per frame
void Update () {
auxTime = TimerScript.getTimeLeft ();
if (auxTime <= 0) {
UpdatePanelText ();
SimulationPanel.SetActive (false);
EndPanel.SetActive (true);
}
}
The bottom script works fine, the top one doesn't. I already dragged the object i want to the script, and it's working for the Debug.Log but as soon i uncomment the _data[2] line in UpdateData() i get the CS0120 error. Any ideas?
The Objects assigned:
sem-titulo.png
(24.9 kB)
Comment