Shorten lines?

Sorry, im new in C# programming. For example:

GameObject.Find (“SnakePart”)

I want to make a variable of this line called “snake” so, everytime i have to call it, i write “snake” instead of writting the entire line. I tried with something like:

GameObject snake = GameObject.Find (“SnakePart”);

However, it doesnt work

Make sure the GameObject you are looking for is Active in the scene hierarchy.

1 Like

You are doing this inside of a function. If you want to access it elsewhere, make it global by placing outside of a function and call GameObject.Find within the Start function.

Sorry, found the problem. I should have tried “transform” because i tried to select a child.

Thanks everyone