Answers for "unity access variables from other scripts"

C#
1

unity access variables from other scripts

public class Accessor : MonoBehaviour {
    void Start()
    {
        GameObject thePlayer = GameObject.Find("ThePlayer");
        PlayerScript playerScript = thePlayer.GetComponent<PlayerScript>();
        playerScript.Health -= 10.0f;
    }
}
Posted by: Guest on January-20-2021

Code answers related to "unity access variables from other scripts"

C# Answers by Framework

Browse Popular Code Answers by Language