why use procedural terrain when we can map the moon? idk
coming with the toughest game to speedrun bois

why use procedural terrain when we can map the moon? idk
coming with the toughest game to speedrun bois

| usingSystem.Collections; | |
| usingSystem.Collections.Generic; | |
| usingUnityEngine; | |
| [RequireComponent(typeof(MeshFilter))] | |
| publicclassMeshGenerator:MonoBehaviour | |
| { | |
| Meshmesh; | |
| Vector3[]vertices; | |
| int[]triangles; | |
| publicintxSize=200; | |
| publicintzSize=200; | |
| // Start is called before the first frame update | |
| voidStart() | |
| { | |
| mesh=newMesh(); | |
| GetComponent<MeshFilter>().mesh=mesh; | |
| StartCoroutine(CreateShape()); | |
| } | |
| privatevoidUpdate() | |
| { | |
| UpdateMesh(); | |
| } | |
| IEnumeratorCreateShape() | |
| { | |
| vertices=newVector3[(xSize+1)*(zSize+1)]; | |
| for(inti=0,z=0;z<=zSize;z++) | |
| { | |
| for(intx=0;x<=xSize;x++) | |
| { | |
| floaty=Mathf.PerlinNoise(x*0.3f,z*0.3f)*2f; | |
| vertices[i]=newVector3(x,y,z); | |
| i++; | |
| } | |
| } | |
| triangles=newint[xSize*zSize*6]; | |
| intvert=0; | |
| inttris=0; | |
| for(intz=0;z<zSize;z++) | |
| { | |
| for(intx=0;x<xSize;x++) | |
| { | |
| triangles[tris+0]=vert+0; | |
| triangles[tris+1]=vert+xSize+1; | |
| triangles[tris+2]=vert+1; | |
| triangles[tris+3]=vert+1; | |
| triangles[tris+4]=vert+xSize+1; | |
| triangles[tris+5]=vert+xSize+2; | |
| vert++; | |
| tris+=6; | |
| yieldreturnnewWaitForSeconds(0.01f); | |
| } | |
| vert++; | |
| } | |
| } | |
| voidUpdateMesh() | |
| { | |
| mesh.Clear(); | |
| mesh.vertices=vertices; | |
| mesh.triangles=triangles; | |
| mesh.RecalculateNormals(); | |
| } | |
| privatevoidOnDrawGizmos() | |
| { | |
| if(vertices==null) | |
| { | |
| return; | |
| } | |
| for(inti=0;i<vertices.Length;i++) | |
| { | |
| Gizmos.DrawSphere(vertices[i],0.1f); | |
| } | |
| } | |
| } |
So Um, moon has lands right? We are using procedural terrain generation for moon's land and boy o boy this thing looks so cool!
Here's a peek:

Uploading the code soon!


| usingSystem.Collections; | |
| usingSystem.Collections.Generic; | |
| usingUnityEngine; | |
| publicclassthirdPlayerMovement:MonoBehaviour | |
| { | |
| publicCharacterControllercontroller; | |
| publicTransformcam; | |
| publicfloatspeed=6f; | |
| publicfloatturnSmoothTime=0.1f; | |
| floatturnSmoothVelocity; | |
| // Update is called once per frame | |
| voidUpdate() | |
| { | |
| floathorizontal=Input.GetAxisRaw("Horizontal"); | |
| floatvertical=Input.GetAxisRaw("Vertical"); | |
| Vector3direction=newVector3(horizontal,0f,vertical).normalized; | |
| if(direction.magnitude>=0.1f) | |
| { | |
| floattargetAngle=Mathf.Atan2(direction.x,direction.z)*Mathf.Rad2Deg+cam.eulerAngles.y; | |
| floatangle=Mathf.SmoothDampAngle(transform.eulerAngles.y,targetAngle,refturnSmoothVelocity,turnSmoothTime); | |
| transform.rotation=Quaternion.Euler(0f,angle,0f); | |
| Vector3moveDirection=Quaternion.Euler(0f,targetAngle,0f)*Vector3.forward; | |
| controller.Move(moveDirection.normalized*speed*Time.deltaTime); | |
| } | |
| } | |
| } |