Mesh Generation : Beginners Guide EP 5 - Unity3D

  Рет қаралды 13,464

CodingWithRus

CodingWithRus

Күн бұрын

Пікірлер: 58
@AliveNotDeadmund
@AliveNotDeadmund Жыл бұрын
For anyone getting a flat mesh without any triangles on it - make sure you turn on 'Selection Wire' under Gizmos in the top-right of your Scene View. :) P.S. You da man, Rus!
@CodingWithRus
@CodingWithRus Жыл бұрын
Ha! Thanks Edmund, and thanks for spreading the knowledge! A really nifty and useful gizmo!
@SudopiaGames
@SudopiaGames Жыл бұрын
Thank you so much
@fabiansinger4300
@fabiansinger4300 3 жыл бұрын
YO this guy is underrated
@CodingWithRus
@CodingWithRus 3 жыл бұрын
Thank you!
@aichayasmine2168
@aichayasmine2168 4 жыл бұрын
You explain things so easily thanks so much for this!
@CodingWithRus
@CodingWithRus 3 жыл бұрын
You're so welcome!
@demarcorr
@demarcorr 2 жыл бұрын
my face when im 9 years into c# and i just learned i can declare and initialize multiple values in the for loop. It makese perfect sense now, ive just never tried it
@LuRybz
@LuRybz 4 жыл бұрын
Thank you for the content. Rus, some suggestions: - Managing the meshes in multiple chunks for performance - Changing the mesh at runtime (the sims Building mode/ Roller Coaster Tycoon 2)
@CodingWithRus
@CodingWithRus 4 жыл бұрын
On it! I've added these to the list 😁
@orderlyhippo1569
@orderlyhippo1569 3 жыл бұрын
Deserves more likes/views
@SaadAli-pv6fh
@SaadAli-pv6fh 4 жыл бұрын
Great series man
@CodingWithRus
@CodingWithRus 4 жыл бұрын
Thank you! :)
@diyguild1327
@diyguild1327 3 жыл бұрын
What is your into song? It's so chill. Also thanks for the video. The more I work meshes the more I'm starting to get the hang of working with them from code
@CodingWithRus
@CodingWithRus 3 жыл бұрын
Hey - happy to hear! sorry I don't really remember the song name as I've made it a long time ago and switched computers. Maybe try to Shazam it? Rus
@diyguild1327
@diyguild1327 3 жыл бұрын
@@CodingWithRus Shazam came in clutch Pomelo - Jobii
@assasino404
@assasino404 3 жыл бұрын
Love the series and this mesh generation is helping me a lot! I did want to ask, how could I spawn objects just like in the procedural placement episode 3 video but here, on mesh. It seems like I'm getting an error when I'm trying to move things across from the code from episode 3 to my mesh generation with the ".transform.position)" line as I don't think I'm clearly stating where I want the object to be positioned maybe?
@CodingWithRus
@CodingWithRus 3 жыл бұрын
Hey! Use the vertices as the point to spawn them in! If you share the code I can take a look. Thanks!
@assasino404
@assasino404 3 жыл бұрын
@@CodingWithRus Here is my the code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class MeshGenerator : MonoBehaviour { //defining our world size public int Worldx; public int Worldz; public GameObject objectToSpawn; //Create a mesh to be our new mesh private Mesh mesh; private MeshCollider meshCollider; //Define the arrays needed for the mesh private int[] triangles; private Vector3[] verticies; // Start is called before the first frame update private List blockPositions = new List(); void Start() { mesh = new Mesh(); GetComponent().mesh = mesh; meshCollider = GetComponent(); GenerateMesh(); UpdateMesh(); blockPositions.Add(verticies.transform.position); SpawnObject(); } void GenerateMesh() { triangles = new int[Worldx * Worldz * 6]; verticies = new Vector3[(Worldx + 1) * (Worldz + 1)]; for (int i = 0, z = 0; z
@CodingWithRus
@CodingWithRus 3 жыл бұрын
@@assasino404 Nice, looks good! I've amended the ObjectToSpawnLocation method and got rid of a few things:) I've recently gotten a new laptop and don't have unity installed on it yet so having to do this on notepad (yikes). I've added comments so that you can easily follow along in case I've missed something. // Create a list to hold our newly spawned Items in our world. List spawnedLocations = new List(); // Here, we are calling for the gameobject (trees) to be spawned in random positions on the blockpositions (cubed grass) private Vector3 ObjectSpawnLocation() { // Get a random point from our vertices array int rndIndex = Random.Range(0, vertices.length); // Assing a random Vertex from our vertices array to newPos Vector3 newPos = vertices[rndIndex]; // Amend our yAxis to not be in the ground newPos.y + 0.5f; // Run a quick check to see if this newly added position already exists in our list if(spawnedLocations.Contains(newPos){ // If it does, re-call method to generate a new point. Debug.Log("Whoops - This space is already taken! Generating a new point!"); newPos = ObjectSpawnLocation(); } //If the new location doesn't exist add it to our list spawnedLocations.add(newPos); // Return the newPos return newPos; } } Hope this helps - if you're having any more issues, I can send you over the whole code with those changes instead of the specific method :) Rus
@assasino404
@assasino404 3 жыл бұрын
@@CodingWithRus Hey Rus, I really appreciate all your help it means a lot! I hate to ask this but I'm getting an error when adding this method in. which is "Assets\MeshGenerator.cs(126,46): error CS1026: ) expected " which is the "if(spawnedLocations.Contains(newPos){" line. I'm not sure if it's me because I've been staring at code the entire day haha. I tried adding a ")" at the end of the line thinking it may work but that only breeds more errors.
@CodingWithRus
@CodingWithRus 3 жыл бұрын
@@assasino404 Hey - Just installed Unity; gonna have a look through your code and see whats up, that method should't be throwing an issue though :/ Will post a link to a gist once done.
@leikiamyrini8849
@leikiamyrini8849 3 жыл бұрын
Can you combine this with the infinite terrain video?
@CodingWithRus
@CodingWithRus 3 жыл бұрын
With a few adjustments and you should be able to! It's a different process of the generation though. I'm considering making a video around this! Thanks.
@Thesupperals
@Thesupperals Жыл бұрын
The code is sound. Unfortunately, I'm coming across an error when you designate your world x and world z larger than 250. I get a rectangle instead of what should be a square. Also, Z fighting/interlacing occurs.
@CodingWithRus
@CodingWithRus Жыл бұрын
Hey, the reason you're getting an error is because of the max amount of vertices a mesh can hold. As a mesh is made up of a 16-bit index buffer, it only supports up to 65,535 vertices. Thanks for the comment!
@anuraagsaxena7942
@anuraagsaxena7942 2 жыл бұрын
I think there is error in code For the triangles for loop Worldx should be added rather than Worldz To go to the next row
@CodingWithRus
@CodingWithRus 2 жыл бұрын
Hey! Shouldn't be as the code that you see if the one that's written :)
@beweldadon
@beweldadon 2 жыл бұрын
It didn't work for me, I've copied the code completely and followed every step and don't know what I am doing wrong. Was there a step I missed?
@CodingWithRus
@CodingWithRus 2 жыл бұрын
Hi, Are there any errors that you're seeing?
@beweldadon
@beweldadon 2 жыл бұрын
@@CodingWithRus no That's the weird thing
@CodingWithRus
@CodingWithRus 2 жыл бұрын
Can you see the mesh field populated? You may have inverted the mesh, move the camera underneath and have a look if you can see it
@beweldadon
@beweldadon 2 жыл бұрын
@@CodingWithRus no, I can't see any mesh, top or bottem
@CodingWithRus
@CodingWithRus 2 жыл бұрын
Have you attached your mesh to a gameObject?
@ductrungg01
@ductrungg01 10 ай бұрын
Guys, change Worldz in his code to Worldx : int tris = 0; int verts = 0; for (int z = 0; z < Worldz; z++) { for (int x = 0; x < Worldx; x++) { triangles[tris + 0] = verts + 0; triangles[tris + 1] = verts + Worldx + 1; triangles[tris + 2] = verts + 1; triangles[tris + 3] = verts + 1; triangles[tris + 4] = verts + Worldx + 1; triangles[tris + 5] = verts + Worldx + 2; verts++; tris += 6; } verts++; }
@iagopaulo2445
@iagopaulo2445 7 ай бұрын
Underrated comment, saved my life thanks dude!
@gorkemdener-wf3ky
@gorkemdener-wf3ky 7 ай бұрын
great correction I was looking for that issue !!
@leafgamedev7709
@leafgamedev7709 3 жыл бұрын
why not work for me? i am using unity 5 please help
@CodingWithRus
@CodingWithRus 3 жыл бұрын
Hi, what exceptions are you seeing? - Rus
@SaadAli-pv6fh
@SaadAli-pv6fh 4 жыл бұрын
Also do a video on sprites
@CodingWithRus
@CodingWithRus 4 жыл бұрын
On it! (flex)
@SaadAli-pv6fh
@SaadAli-pv6fh 4 жыл бұрын
I have a script which add gradient to any sprite and we can animate the gradient i believe its using the vertex coloring at runtime.. so if possible can you do a video ... I can send you the script
@kirayt249
@kirayt249 2 жыл бұрын
I GOT SOME MESH BUT BETWEEN LIKE FEW GRIDS THERE AN EMPTY ONE WTF HOW TO SOLVE IT PLZ
@kirayt249
@kirayt249 2 жыл бұрын
AND THAT ONLY HAPPEN WHEN I CHOOSE DIFFERENT WORLDZ AND WORLDX WHEN THEY MATCH EACH OTHER THERE NO EMPTY GRIDS
@CodingWithRus
@CodingWithRus 2 жыл бұрын
Hi, it sounds like you're exceeding the vertex limit of the mesh. No caps next time please ;). Rus
@LM-cc7qz
@LM-cc7qz 3 жыл бұрын
bruh imagine straight up copying brackeys code and then making the same tutorial with it without even mentioning that you "borrowed" their code.
@CodingWithRus
@CodingWithRus 3 жыл бұрын
Hi, I've seen brackeys tutorial but can assure you there was no code stealing. Can you show me a different way of generating a mesh? The formula is the same throughout to generate a plane but open to see a few suggestions :) Rus
Node System : Beginners Procedural Generation EP 6 - Unity3D
14:02
CodingWithRus
Рет қаралды 10 М.
Mesh Deformation : Beginners Procedural Generation EP 7 - Unity3D
11:25
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
MESH GENERATION in Unity - Basics
11:10
Brackeys
Рет қаралды 460 М.
Infinite Terrain : Beginners Guide EP 4 - Unity3D
9:22
CodingWithRus
Рет қаралды 16 М.
PROCEDURAL TERRAIN in Unity! - Mesh Generation
13:35
Brackeys
Рет қаралды 612 М.
Moebius-style 3D Rendering | Useless Game Dev
8:12
Useless Game Dev
Рет қаралды 857 М.
Procedurally Generated 3D Dungeons
9:42
Vazgriz
Рет қаралды 297 М.
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,6 МЛН
Much bigger simulation, AIs learn Phalanx
29:13
Pezzza's Work
Рет қаралды 2,8 МЛН
How To Slice Meshes In Unity
4:43
Tvtig
Рет қаралды 90 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН