I have the following code in C#:
GameObject[] obj = GameObject.FindGameObjectsWithTag("Player");
foreach(GameObject o in obj)
{
o.transform.position = new Vector3(o.transform.position.x, o.transform.position.y + 5,
o.transform.position.z);
Health h = o.GetComponent<Health>();
}
It all works fine save for the line Health h = o.GetComponent(); and the reason for this is the type Health is undefined.
Health is a js script which can be accessed by js functions simply as ‘Health’, but as far as I can see there is no way to find it in C#.
Is this just a limitation of Unity’s scripting system (which would be understandable) or can this be done and I’m just going about it the wrong way?