I am following a tutorial to draw a grid in unity, and there is a line
obj.GetComponent().x = i;
in the script, but unity thinks GridStats is a variable. Why is that? Is there something I need to add?
Pretty sure there is no component with that name. Without seeing more code or the tutorial you’re working from, hard to say more.
id guess its something the tutorial has made, or is about to make
It’ll be in the tutorial. You either missed it or it’s later on in the video.
6:57, line 32 showed the line of code with that component, I did not see him doing anything that creates the component.
Then go look again. It’s not called GridStats but it’s VERY close to that.
Two steps to tutorials and / or example code:
- do them perfectly, to the letter (zero typos, including punctuation and capitalization)
- stop and understand each step to understand what is going on.
If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning.
EDIT: this tutorial has errors actually… in one place he calls it GridStat and another it is GridStats… almost 100% sure that is supposed to be one name (pick one), not two.
He also misspells GridBehaviour as GridBehaviou so it’s definitely careless.
While we’re talking movement in a grid, look for scenes with the word “grid” in them in my proximity buttons project. proximity_buttons is presently hosted at these locations:
To be fair they make a script called GridStat at about 3:30. Though they write GridStats for some reason at 6:57. I can’t see if they rename at any point.
Seems like a pretty terrible tutorial to be honest. No wonder some folks struggle to learn Unity when poor videos like that are common.
Yeah, that video has had no proofreading or editing performed on it. You can see another class name typo at 7:08 and I’m confident there are many more, and if you look at the comments on the video he didn’t even show how to perform movement on the grid.

oh, I did not notice they made the script at 3:30 thank you, I dont know what I was doing
I made the script and applied the behaviour script to another object, but nothing is generating
I’ve been reading through more of the comments and some of them point out the code that he demos at the end isn’t the code in the video. I checked to see if a link was provided to download it but it just points to a long dead Patreon. So the code in the video is not only poorly written but also apparently non-functional.
I see
Moral of the story: find another tutorial. That one appears to be a waste of time.
It’s crap like that makes me want to start making video tutorials, as I know I can do better work than that.
On the other hand I have projects to work on…
Code Monkey has an entire playlist of tutorials on this topic.
I am going through another tutorial that seems to best fit with what I am doing, but I am stuck on the step of turning on grid snapping. I have tool hand rotation set to global, but grid snapping stays locked.