- Home /
Decipher 2 lines of code please
Whats is m_Terrain being assigned as in following lines of code?
Is this just a funny way to say m_Terrain = terain?
Transform terain = GameObject.Find("Terrain");
m_Terrain = terain.GetComponent(typeof(Terrain)) as Terrain;
Comment
Best Answer
Answer by FL · May 05, 2013 at 06:58 PM
The first line picks a GameObject named "Terrain" (this is just a object name). The second line picks a Terrain component for the object in the first line. This is the way to access the Terrain class from a GameObject and use its own methods/attributes.
Take a look at the examples at http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html
I see now - I was assu$$anonymous$$g that the GameObject holding the Terrain class was the Terrain class and not just the container. Thanks