how to read public verible in another script unity c# code example
Example 1: how to read public verible in another script unity c#
public class Accessor : MonoBehaviour {
void Start()
{
GameObject thePlayer = GameObject.Find("ThePlayer");
PlayerScript playerScript = thePlayer.GetComponent<PlayerScript>();
playerScript.Health -= 10.0f;
}
}
Example 2: how to read public verible in another script unity c#
public class Accessor : MonoBehaviour { void Start() { GameObject thePlayer = GameObject.Find("ThePlayer"); PlayerScript playerScript = thePlayer.GetComponent<PlayerScript>(); playerScript.Health -= 10.0f; }}