I am trying to get the tag of the parent of a collider:
_____Hierarchy_____
| EmptyGameObject | <-- Has the tag "Generator"
| ColliderObject | <-- Gets hit by Raycast (Has the collider)
|___________________|
But i get a error. I have no idea how to fix it.
The error is at line: 1
else if (hit.collider.transform.parent.gameObject.tag == "Generator" && Input.GetKeyDown ("e"))
Script:
else if (hit.collider.transform.parent.gameObject.tag == "Generator" && Input.GetKeyDown ("e"))
{
if (Fuel >= 100)
{
Fuel -= 100;
Generator.Machine_Fuel += 100;
ES2.Save(Fuel, "Data/Player/Inventory/Fuel.txt");
Debug.Log ("100ml Fuel added to machine");
// txtRef.text = "Apples: " + apples;
}
else
{
Generator.Machine_Fuel += Fuel;
Fuel -= Fuel;
}
}
Thanks!
-shinevision