Hi new to the coding business, some code was a little bit of a copy/paste, but some original, I I keep getting errors and stuff, but I am sure its about my nodes.
It asks me to rename it, I rename it and then it throws a whole bunch more errors I changed the other veriables associated with it, and now its back to square 1, same error, same issue.
So to learn from my mistake, and correct me if I’m wrong. I used a Geometry when I should have been using a Spatial (because I used an imported model), in line 33. and in line 53 why do i need to remove Spatial? I just don’t understand why? Sorry If I sound really inquisitive, I am just trying to learn. and thank-you for the help.
<cite>@JohnZamoider said:</cite>
So to learn from my mistake, and correct me if I'm wrong. I used a Geometry when I should have been using a Spatial (because I used an imported model), in line 33. and in line 53 why do i need to remove Spatial? I just don't understand why? Sorry If I sound really inquisitive, I am just trying to learn. and thank-you for the help.
Basically when you added spatial in front of that variable you created a new variable that’s scope was only local to that method. In other words you weren’t assigning it to the variable that you declared in your class. So in your update loop you tried to call a method on an object that had never been initialized. By removing Spatial your code correctly assigned the value to your class variable.
You should have had a warning about a local variable hiding a field. The local variable “Spatial whatever” was hiding the field “Spatial whatever”.
I will caution you that learning to program Java from ground zero while also learning to write 3D games is just about the hardest thing you can do. Like learning to shave while riding a bike standing up on the seat… when you’ve never learned to ride a bike before. You will get hit with 1000 impossible problems that would simply go away if you spent a few weeks/months learning the language a little bit on some simpler projects.
<cite>@pspeed said:</cite>
You should have had a warning about a local variable hiding a field. The local variable "Spatial whatever" was hiding the field "Spatial whatever".
I will caution you that learning to program Java from ground zero while also learning to write 3D games is just about the hardest thing you can do. Like learning to shave while riding a bike standing up on the seat… when you’ve never learned to ride a bike before. You will get hit with 1000 impossible problems that would simply go away if you spent a few weeks/months learning the language a little bit on some simpler projects.
Actually I was looking for errors that would help me out in the debugging, but it didn’t all it suggested was to rename the variable.
@JohnZamoider said:
Actually I was looking for errors that would help me out in the debugging, but it didn't all it suggested was to rename the variable.
Then you didn’t do it right. If you hover over the light bulb then it tells you what’s wrong. If you click on it then it gives you possible solutions.
For example, I artificially setup exactly this basic beginner’s scoping problem and hovered over the lightbulb: