tag:blogger.com,1999:blog-5616321214723803595.post8772928003439262779..comments2024-03-13T09:57:10.000-07:00Comments on Student Game Dev has moved!: Unity Voxel Tutorial Part 7: ModifyingAnonymoushttp://www.blogger.com/profile/11218854695223703316noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-5616321214723803595.post-70669444154118805832018-05-27T13:41:48.506-07:002018-05-27T13:41:48.506-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/10621921616604337720noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-17316296101434333452017-10-16T18:31:13.580-07:002017-10-16T18:31:13.580-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/08966415009582718793noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-81894084831644010932015-05-01T21:32:54.383-07:002015-05-01T21:32:54.383-07:00In your Start() function, did you actually set the...In your Start() function, did you actually set the world variable to anything? It should be "world = gameObject.GetComponent();"Anonymoushttps://www.blogger.com/profile/13640409449215389726noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-60178266534823610822015-02-18T09:28:14.771-08:002015-02-18T09:28:14.771-08:00I wonder if it is possible to use this with custom...I wonder if it is possible to use this with custom meshes, not just blocks. Such as halfblocks, stairs, ect. or even more complex meshes.TheSilentParadoxhttps://www.blogger.com/profile/17157670130613574601noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-8964955936887098412015-01-15T05:47:56.708-08:002015-01-15T05:47:56.708-08:00does this also work with the marching cubes algori...does this also work with the marching cubes algorithm?Anonymoushttps://www.blogger.com/profile/11101456337145819474noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-33265697693668435562014-12-13T05:15:38.912-08:002014-12-13T05:15:38.912-08:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/08655814776173264038noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-78206762777591646892014-10-31T20:44:21.919-07:002014-10-31T20:44:21.919-07:00Hello,
i am running into a problem during this pa...Hello,<br /><br />i am running into a problem during this part.<br /><br />When i try to place or remove blocks. i get an error. i have already added the modifyterrain script to the world object, so thats no fix for my problem.<br /><br />error:<br /><br />NullReferenceException: Object reference not set to an instance of an object<br />ModifyTerrain.SetBlockAt (Int32 x, Int32 y, Int32 z, Byte block) (at Assets/Scripts/ModifyTerrain.cs:125)<br />ModifyTerrain.SetBlockAt (Vector3 position, Byte block) (at Assets/Scripts/ModifyTerrain.cs:115)<br />ModifyTerrain.ReplaceBlockAt (RaycastHit hit, Byte block) (at Assets/Scripts/ModifyTerrain.cs:94)<br />ModifyTerrain.ReplaceBlockCursor (Byte block) (at Assets/Scripts/ModifyTerrain.cs:68)<br />ModifyTerrain.Update () (at Assets/Scripts/ModifyTerrain.cs:21)<br /><br />code chunk from error:<br /><br /> public void SetBlockAt(int x, int y, int z, byte block) {<br /> //adds the specified block at these coordinates<br /> <br /> print("Adding: " + x + ", " + y + ", " + z);<br /> <br /> <br /> --> world.data[x,y,z]=block;<br /> UpdateChunkAt(x,y,z);<br /> <br /> }<br /><br />the line marked with the arrow should be faulty according to the log.<br /><br />hope you can help me with this.Anonymoushttps://www.blogger.com/profile/08412531987432759066noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-88556801040438552672014-06-16T21:50:39.308-07:002014-06-16T21:50:39.308-07:00I know that this tutorial is a bit old but im stil...I know that this tutorial is a bit old but im still following it. Im able to add and remove voxels, but only in a diagonal line from the origin. The grid is also not inline for me and I cant find where to put:<br />chunks[x,y,z]=Instantiate(chunk,<br /> new Vector3(x*chunkSize-0.5f,y*chunkSize+0.5f,z*chunkSize-0.5f),<br /> new Quaternion(0,0,0,0)) as Chunk;<br /><br />Help is needed :X<br />Thanks!Anonymoushttps://www.blogger.com/profile/09137682291219904907noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-44035123314199956802014-05-10T10:09:38.332-07:002014-05-10T10:09:38.332-07:00Ok. Found an dirty work arround. I moved the chunk...Ok. Found an dirty work arround. I moved the chunk back to 0,0,10. Now it gets rendered in the distance. No fix but a dirty workarround http://puu.sh/8GQ1G.pngLeemanhttps://www.blogger.com/profile/03991037328328844352noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-28637526251818466902014-05-10T10:06:59.753-07:002014-05-10T10:06:59.753-07:00Sorry for the name "Unknown" never comme...Sorry for the name "Unknown" never commented on Blogspot before ;)Leemanhttps://www.blogger.com/profile/03991037328328844352noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-17040827115583217592014-05-10T10:06:04.203-07:002014-05-10T10:06:04.203-07:00Hey Alexandros.
First off all. Great tutorial. Re...Hey Alexandros.<br /><br />First off all. Great tutorial. Really like it. I run into a little problem I did not looked further into it quite yet. Will do it after I posted here and if I come up with a soultion I will post it. Would be great though if you have an answer aswell incase I should not find it.<br /><br />Ok following problem: When rendering the chunks it creates copy of the Original GameObject which is intended. However the original GameObject stays intact but is dispositioned<br /><br />http://puu.sh/8GPER.jpg<br /><br />as you can see there are blocks in other blocks just a bit off to the side. So after I move the original gameobject that gets copied a bit away it looks as intented<br /><br />http://puu.sh/8GPMx.jpg<br /><br /><br />Leemanhttps://www.blogger.com/profile/03991037328328844352noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-53740382306932192432014-04-12T01:56:16.698-07:002014-04-12T01:56:16.698-07:00Hello Alexandros.
I just wanted to add this comme...Hello Alexandros.<br /><br />I just wanted to add this comment outside of the reply I accidentally posted above. Thanks a lot for your hard work by the way!<br /><br />For anyone who pursues this further than the tutorials and begins working on their own project, I wanted to share a common problem I ran into.<br /><br />If you are using a First-Person controller, and attempt to change a block beneath you, the AddBlockCenter function will actually raycast into any graphics you use for your first-person camera controller!<br />I did a little digging around, and you can actually change the flags for the controller to ignore raycasting. Just a helpful tip!Anonymoushttps://www.blogger.com/profile/05634173888634771124noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-45285946876814767142014-04-12T01:43:07.430-07:002014-04-12T01:43:07.430-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/05634173888634771124noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-61461312689658024602014-03-12T20:52:57.150-07:002014-03-12T20:52:57.150-07:00Thank you so much for replying, and so quickly.
I ...Thank you so much for replying, and so quickly.<br />I had changed something in World.cs where the temporary Chunk object is instantiated. For the life of me, I cannot think why I made the change. Once I fixed it, things started working as expected.Anonymoushttps://www.blogger.com/profile/01839189317312364128noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-18603042693213424332014-03-12T15:45:37.458-07:002014-03-12T15:45:37.458-07:00Make sure your gameobject with world.cs isn't...Make sure your gameobject with world.cs isn't too low, I think it's supposed to be placed at 0,0,0. The script uses the world coordinates of the ray cast hit to decide what block was there but if the terrain isn't where it expects it to be it returns the wrong position.Anonymoushttps://www.blogger.com/profile/11218854695223703316noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-62776699747119077732014-03-12T14:49:14.030-07:002014-03-12T14:49:14.030-07:00Hi :)
Thank you for such great tutorials.
When I ...Hi :)<br />Thank you for such great tutorials.<br /><br />When I try to modify blocks, the ray cast is returning negative values on the y axis:<br />"Adding: 18, -4, 16"<br /><br />Which in turn generates an error:<br />IndexOutOfRangeException: Array index is out of range.<br />(wrapper managed-to-managed) object:ElementAddr (object,int,int,int)<br />ModifyTerrain.SetBlockAt (Int32 x, Int32 y, Int32 z, Byte block) ...<br /><br />Have I made a simple mistake somewhere that would cause this?Anonymoushttps://www.blogger.com/profile/01839189317312364128noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-58880604259033272022014-01-29T02:13:54.001-08:002014-01-29T02:13:54.001-08:00At the end of the function UpdateChunkAt() right a...At the end of the function UpdateChunkAt() right after the line world.chunks[updateX,updateY, updateZ].update=true;Anonymoushttps://www.blogger.com/profile/11218854695223703316noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-45029485724058443522014-01-27T03:20:02.188-08:002014-01-27T03:20:02.188-08:00Updating the mesh on a single chunk seems to be pr...Updating the mesh on a single chunk seems to be pretty laggyAnonymoushttps://www.blogger.com/profile/01633511838389545173noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-50278319663912162122014-01-27T01:17:35.478-08:002014-01-27T01:17:35.478-08:00where does this go ?
if(x-(world.chunkSize*update...where does this go ?<br /><br />if(x-(world.chunkSize*updateX)==0 && updateX!=0){<br /> world.chunks[updateX-1,updateY, updateZ].update=true;<br />}<br /> <br />if(x-(world.chunkSize*updateX)==15 && updateX!=world.chunks.GetLength(0)-1){<br /> world.chunks[updateX+1,updateY, updateZ].update=true;<br />}<br /> <br />if(y-(world.chunkSize*updateY)==0 && updateY!=0){<br /> world.chunks[updateX,updateY-1, updateZ].update=true;<br />}<br /> <br />if(y-(world.chunkSize*updateY)==15 && updateY!=world.chunks.GetLength(1)-1){<br /> world.chunks[updateX,updateY+1, updateZ].update=true;<br />}<br /> <br />if(z-(world.chunkSize*updateZ)==0 && updateZ!=0){<br /> world.chunks[updateX,updateY, updateZ-1].update=true;<br />}<br /> <br />if(z-(world.chunkSize*updateZ)==15 && updateZ!=world.chunks.GetLength(2)-1){<br /> world.chunks[updateX,updateY, updateZ+1].update=true;<br />}<br />Anonymoushttps://www.blogger.com/profile/01633511838389545173noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-4864135335285888162014-01-24T08:00:12.399-08:002014-01-24T08:00:12.399-08:00Hello friend,
I had the same problem and solved it...Hello friend,<br />I had the same problem and solved it by applying the "ModifyTerrain" script to the World GameObject, because in the start () function, it tries to acces the world component which is only present on the World GameObjectAnonymoushttps://www.blogger.com/profile/16054128863737365888noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-84929245710601113282013-12-20T17:22:33.934-08:002013-12-20T17:22:33.934-08:00I am also getting an error at the line: world.data...I am also getting an error at the line: world.data[x, y, z] = block;<br />That is within SetBlockAt () And the error specifically says this: <br />NullReferenceException: Object reference not set to an instance of an object<br />ModifyTerrain.SetBlockAt(Int32 x, Int32 y, Int32 z, Byte block)Anonymoushttps://www.blogger.com/profile/00643465342389829434noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-90279837896668362802013-12-11T11:37:42.552-08:002013-12-11T11:37:42.552-08:00Can you send me a link for your ModifyTerrain.cs ,...Can you send me a link for your ModifyTerrain.cs , World.cs nd Chunk.cs scripts, I seem to be having some errors coming up saying NullReferenceException : Object reference not set to an instance of an objet.ashleychttps://www.blogger.com/profile/16025804646720358406noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-79325662429467648752013-10-17T12:46:31.573-07:002013-10-17T12:46:31.573-07:00Ok, I made it clear where I meant to make changes ...Ok, I made it clear where I meant to make changes to the chunk updating and added the faceCount=0; to the previous part. Thanks for figuring these out and letting me know, I sure everyone else who does the tutorial will really appreciate this!Anonymoushttps://www.blogger.com/profile/11218854695223703316noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-32664718301916990102013-10-17T11:24:36.347-07:002013-10-17T11:24:36.347-07:00Ok I solved 2.
It had 2 errors:
1. I changed som...Ok I solved 2.<br /><br />It had 2 errors:<br /><br />1. I changed some lines, that was causing the out of bounds errors (index errors as I said).<br /><br />2. Chunk.GenerateMesh needs to reset faceCount back to zero at the end so new calls don't make more than 2 triangles per face. So just "faceCount = 0;" at the bottom of GenerateMesh (Chunk.cs) and voilá!ratnushockhttps://www.blogger.com/profile/06173129660278212491noreply@blogger.comtag:blogger.com,1999:blog-5616321214723803595.post-89803584047296126202013-10-17T10:49:28.600-07:002013-10-17T10:49:28.600-07:00Hi again Alexandros,
Just two things:
1. " ...Hi again Alexandros,<br /><br />Just two things:<br /><br />1. " Now instead of calling the GenerateTerrain function just set update to true: " this paragraph should say we are about to make changes to "UpdateChunkAt" (I guess) and also we don't need to call "GenerateMesh".<br /><br />2. I get index errors when placing a block and "Failed setting triangles. Some indices are referencing out of bounds vertices." when removing. Did I miss something?<br /><br />That's all, it's been a entertaining tutorial!ratnushockhttps://www.blogger.com/profile/06173129660278212491noreply@blogger.com