and i tried to make the same process on my android game project but nothing happened.I couldnt figure out the problem.I will be so glad if you guys help me.Here is my map;
That error message below left is basically saying that they object doesn’t exist. Null. My guess is you have not connected it. The script you posted is for the CylinderManager but in the photo you have the player selected so it is hard to see if the GameObject is attached to the code.
Also, it just seems odd to me but I tend to learn new code all the time but I have never seen before but the parameter in your SpawnTile method, prefabIndex you try to assign a -1 to it there which I have never seen anyone try to assign anything in that area of code before. But then in the body of the code, of that method you do not use the prefabIndex. Also in the different areas where you call the SpawnTire() you do not pass in any arguments.
I stand corrected, I looked at the tutorial and he does in deed write his code like you did and it works, I have just never seen it like that before. But your Null reference is more then likely due to you not connecting you prefab to the public field on the game side of the code.
the ‘-1’ is a default parameter. Those can be useful, when you think a method will use that parameter more often (at least, that’s my opinion on the matter).
In this situation, it’s odd, because it’s never used… Maybe later it’s used in some updated code, I have no idea. Maybe it’s there because they thought they’d use it, but never got around to it
You can send it a value there, to replace that option, or just leave it…
When you get a null ref error, it usually tells you on what line it happened. Then, you can use that to look into the issue, and at the very least, if you’re still stumped for some reason, post the line on the forums
Anyhow, if the previous poster is correct, and you’re asking how to fix that… you drag your prefab into the public variable on the script …
If that’s the line that’s the problem… For example, if it’s the cylinderPrefabs that’s the problem, then just drag the prefab onto the script and it will automatically add it there.
If it’s something else, please just write down the line number as it corresponds to the code you posted on the forums
Okay, I don’t think the line matches up exactly with what you posted here in the forums, but if it’s the instantiate call…
did you drag the prefab into the inspector where it says cylinderPrefabs?
Not drag the script, but the prefab in the project assets?
Okay, well then that’s all good… Is the line 29 equal to the instantiate call? You didn’t confirm that… just to rule anything out. In the code you posted, line 29 is only " { "
Well, that explains a lot more… okay – see the error line you posted didn’t match the code you posted on the forums. When that happens, you should tell people what the line is on the forums, too
so the problem is almost certainly with ‘playerTransform’. Make sure you have a game object with that tag in the scene. In your start method, you can check if it’s null after you look for it… and confirm if that’s the issue, etc…
From there you should be able to start getting it all together…