Question by
Jaskirat · Jul 02, 2017 at 09:03 AM ·
public variable
How do you access variables from a different script?
I know this has probably been answered before, but there has to be a better way to do this!
I am trying to modify the roll a ball game from the Unity tutorials. I want the ground to reduce in size by 10% every time the player rolls off the map. I thought the best way to do so would be to create a 'deathcounter' variable under the player gameobject, and then reduce the ground size accordingly. But I do not know how to access the deathcounter variable under the ground gameobject. So, in summary, how do I access variables from another script in Unity? Or is there a better way to solve my problem? (Reduce ground size when player falls off the map)
Using Unity 5.6.1, programming with C#.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612125312im_/https://answers.unity.com/themes/thub/images/avi.jpg)