Creating in Unity #5: Combining Meshes!

  Рет қаралды 100,481

Craig Perko

Craig Perko

Күн бұрын

Пікірлер: 171
@petarpetrovic4893
@petarpetrovic4893 7 жыл бұрын
The way he explains is so perfect, this is the process of thinking and how everyone should learn programming and I would recommend Craig to everyone to watch!
@darketomaly
@darketomaly 2 жыл бұрын
If you're wondering how to save the mesh, just place this at the end of the code. AssetDatabase.CreateAsset(finalMesh, $"Assets/{name}-{GUID.Generate()}.mesh"); AssetDatabase.SaveAssets();
@greatstaro9255
@greatstaro9255 4 жыл бұрын
You are the first one explaining this on the internet, thank you!
@VectorIV
@VectorIV 7 жыл бұрын
"Delete all the children."
@theairaccumulator7144
@theairaccumulator7144 6 жыл бұрын
Lol
@soaringsquid0.129
@soaringsquid0.129 4 жыл бұрын
Hide ya kids, cuz he gonna fetus deletus RIP both memes from this comment Cause of death: Time
@blueIgle
@blueIgle 3 жыл бұрын
Master Skywalker, there are too many of them, what are we going to do? delete all the children
@DarkDax
@DarkDax 5 жыл бұрын
Just binge watched some of your videos and I have to say they’re incredible. Well paced, well explained, and not too serious. Love it, keep it up!
@GodslayerXUL
@GodslayerXUL 4 жыл бұрын
Such a good tutorial. You seem like a really nice guy and make those videos very pleasant to watch. This also solved my problem, as I noticed my performance dropped significantly once I finished my level. I first suspected my scripts, but it was actually the physics system being overwhelmed by 3000+ meshes (spikes in a platformerr) with mesh colliders. After combining just a few big chunks my CPU times dropped from 23ms to 11ms. Thank you!
@RaebEeffoc
@RaebEeffoc 2 жыл бұрын
This was exactly what I was looking for. Managed to gain a decent amount of FPS with this! Thank you very much
@SillyFennecsForever
@SillyFennecsForever Ай бұрын
Such a nice tutorial. It is really well made
@rodgermccallister1606
@rodgermccallister1606 4 жыл бұрын
Fantastic tutorial! After watching three other tutorials, this is the first one that made me actually understand what was happening. Your method of teaching is amazing, subscribing now!
@UserRandomized
@UserRandomized 4 жыл бұрын
Awesome tutorial!! Those who truly wish to learn new techniques understand that it takes time. I noticed you mentioned the video being 20 minutes was an issue, but it isn't an issue at all. It was a very informative video and I learned a lot from it.
@civil1
@civil1 5 жыл бұрын
ahhhh "Do the rotation first, because rotation might change the position" You just solved my problem, thankyou! (The rotation of the combined mesh was occasionally subtly wrong)
@AesnasSticks
@AesnasSticks 4 жыл бұрын
0:25 "It'd be a total *mesh*" Get it? :D
@shadowyt6038
@shadowyt6038 4 жыл бұрын
okie............ xD
@aryanbaburajan
@aryanbaburajan 3 жыл бұрын
@@shadowyt6038 Holy Cow its ridiculously stupid and crazy how I managed to find a comment of my old account lmao I don't even remember watching the tutorial!!
@fafase
@fafase 8 жыл бұрын
This is a video of the Mesh.CombineMesh script from Unity docs. And in the same way, it does not consider going over the limit vertex amount (65k). You should be keeping track of the vertex count and create a new object when reaching the limit.
@rikkcarey
@rikkcarey 8 жыл бұрын
Awesome tutorial! Enjoyed your sense of discovery and beginner's mind!
@myrzagali.alikhan
@myrzagali.alikhan 2 жыл бұрын
Thanks, you solved my problem with positon. Well explained! :D
@DePistolero
@DePistolero 6 жыл бұрын
I felt like at home man... like listening to my brain go about things, only you knew exactly what were you doing :) My brain usually doesn't :) So I spend a couple of hours on YT and videos like this one.... THANK YOU :) :) :)
@EXHOUL
@EXHOUL 4 жыл бұрын
If anyone is getting a different size mesh as a result, you can also store the original scale too. Make sure you update it before the position and rotation :)
@shihmeng91
@shihmeng91 8 жыл бұрын
this is a great tutorial, just wish that you could complete it, as for the issues for different shared or texture is use.
@CraigPerko
@CraigPerko 8 жыл бұрын
I figured most of my viewers wouldn't need that, but it's not too complex. If you need a lot of functionality, I recommend downloading something from the asset store - there's a lot of mesh combiner libraries available.
@simbioscope3076
@simbioscope3076 4 жыл бұрын
I know this is a bit old but it has really helped me to understand what the heck was going on, I wasnt able to do it with my model and dunno why its not working maybe because of the model, I will test it with a simple one to see if it´s because of the model. Thank you for this video.
@inframatic
@inframatic 8 жыл бұрын
At first I thought "Why does this video exist since Unity has had a CombineMeshes method since 2011. Then I realized that the CombineMeshes doesnt work at all and especially if the object is so big that it has many submeshes
@ewwitsantonio
@ewwitsantonio 6 жыл бұрын
Really enjoy your teaching method!! Great stuff. Very easy to follow your train of thought and method. :)
@ThatOneXander
@ThatOneXander 8 жыл бұрын
I never knew i needed to know this until i watched your video. Thank you and keep up the videos, Subscribed
@RealToOy
@RealToOy 5 жыл бұрын
Great tutorial! Couple of questions though.. -How can I keep the materials programmatically? I noticed you did it with drug and drop. -What happens if the children have different materials? In other words, how do I keep the same texturing programmatically so i dont have the purple oject but the exact original one? Obviously if the object has one material we can apply like: Material theMaterial= Resources.Load("theMaterialName", typeof(Material)) as Material; GetComponent().material = theMaterial; But what if it has multiple materials? Thanks!!
@joeysipos
@joeysipos 2 жыл бұрын
This was an awesome tutorial! Thank you so much! Exactly what I needed!
@CraigPerko
@CraigPerko 2 жыл бұрын
It's getting pretty old, I think some of the details have changed. I don't use Unity any more, so I couldn't say for sure.
@joeysipos
@joeysipos 2 жыл бұрын
@@CraigPerko worked perfectly in Unity 2020!
@joeysipos
@joeysipos 2 жыл бұрын
@@CraigPerko why did you stop using Unity?
@CraigPerko
@CraigPerko 2 жыл бұрын
@@joeysipos The company that owns it is incompetent. They're desperately chasing Unreal instead of aiming to provide a decent engine, and that will never work because Epic has literally 1000x more money. It's destroying the engine.
@joeysipos
@joeysipos 2 жыл бұрын
@@CraigPerko I don’t know if that true though. I looked it up and Unity owns like 65% of video game market share vs 13% for unreal. For AAA games it’s a great engine. But Indie dev like myself I am in love with Unity! Both have pros and cons.
@LuRybz
@LuRybz 7 жыл бұрын
Man, you are in another level. Seriously, congratulations. Where did you learn all of this (Games in general)? I am really interested in this Editor, for a huge personal project. This is pure modularity, awesome.
@HaikelTV
@HaikelTV 7 жыл бұрын
this is Mesh.CombineMesh from unity docs ... he didn't do anything other than copying the code from unity docs docs.unity3d.com/ScriptReference/Mesh.CombineMeshes.html
@erfanzandi1362
@erfanzandi1362 Жыл бұрын
wow great video
@danielstoy171
@danielstoy171 5 жыл бұрын
Thanks for this tutorial! Really helped out with optimizing my scene
@ozanyokuva6930
@ozanyokuva6930 4 жыл бұрын
I have 2 things to say , but first I must say , you gave me a perspective. First thing , now my scene file is 300MB... and outpur APK is 100MB which is caused by massive header files. You should also show how to make these meshes a prefab dude. Second is , it is better to search the scene and get the mesh from a same object of your object instead of recreating it . You dont need to create the same mesh if you already created it with a clone of your object. doing this lowered my scene file size but I still have the file headers size problem although I am using the same mesh for same type of objects :/
@LasseloH
@LasseloH 8 жыл бұрын
Thank you so much for this, this tutorial is gold
@sadoqdraws1170
@sadoqdraws1170 3 жыл бұрын
Thanks to Allah for sending you to explain all these stuff and thank you men for all the effort you put out there!
@bogdan1115
@bogdan1115 6 жыл бұрын
Great step by step explanation! And furthermore, your voice is funny :D
@gregoryosborne6346
@gregoryosborne6346 4 жыл бұрын
Phew, thank you so much. Very clear.
@StillNight77
@StillNight77 6 жыл бұрын
This was amazingly helpful, thank you.
@zedgamedev
@zedgamedev 6 жыл бұрын
Thanks Bro!! Works exactly the way it should.
@kaneaustin8708
@kaneaustin8708 4 жыл бұрын
combine mesh instance 0 is null... can't find a solution to my problem anywhere.
@CraigPerko
@CraigPerko 4 жыл бұрын
You probably didn't initialize your combine mesh instances properly.
@malcolmhollett8638
@malcolmhollett8638 7 жыл бұрын
Very great video, huge help, thanks.
@jameslavery2958
@jameslavery2958 8 жыл бұрын
Wow! That was awesome. Thank you very much.
@AkkiAdachi
@AkkiAdachi 5 жыл бұрын
why dont you have a simeple copy paste in the discription
@jakemarcus9999
@jakemarcus9999 2 жыл бұрын
MeshCombiner editor doesn't find the MeshCombiner script for some reason. I don't find a reason why.
@GudJuJuTV
@GudJuJuTV 7 жыл бұрын
So from an optimization standpoint, does this reduce the amount of faces that need to be rendered? i.e. removing redundant pieces that can't be seen
@CraigPerko
@CraigPerko 7 жыл бұрын
No. It just manually optimizes how many objects are in the scene, and may reduce the number of draw calls.
@wurty
@wurty 6 жыл бұрын
What about shadow casters?
@jeromej.8726
@jeromej.8726 6 жыл бұрын
Maybe someone already said it but that'd be cool to have the source code available online :) (even if it's only a few lines of code. I'm coming back to this vid and I gotta rewatch it to get the code back instead of clicking some link in the description :P)
@elizaknight6980
@elizaknight6980 7 жыл бұрын
amazing, thanks so much :) I will try this for my game
@johnchapman5858
@johnchapman5858 6 жыл бұрын
fantastic tutorial thank you!
@mzijewel
@mzijewel 6 жыл бұрын
Thank You very much for your effective tutorial.
@SimantoRahman
@SimantoRahman 6 жыл бұрын
Hey amazing tutorial. Is there any way to do this without using the CombineInstance class? I wanted to know if there are any hands-on way to do combining of vertices, triangles, uv maps and what not. I'm under the impression that will be faster...
@CraigPerko
@CraigPerko 6 жыл бұрын
It won't be faster, but yes, you can. The problem is the vast number of possible things you'll need to combine - submeshes, verts, uvs, colors, uv2s, bone mounting, etc.
@sallerc
@sallerc 7 жыл бұрын
Interesting, but you should really increase the fontsize (or lowering the resolution) when recording.
@Zil67
@Zil67 3 жыл бұрын
I keep getting the error "The namespace '' already contains a definition for 'MeshCombiner'" What do I do?
@SpicyMelonYT
@SpicyMelonYT 3 жыл бұрын
Its been 4 months so I doubt you still have this problem but I would assume that the error is telling you that unity now has a MeshCombiner Class. So maybe you can use it to do what this video shows off but if not then just name it something else. Like MyMeshCombiner or MeshesCombiner
@lazyemperor5182
@lazyemperor5182 3 жыл бұрын
Its 2021, So Do we Have a shortcut way IN Unity 2019 or above for oneclick Mesh Combining Or Somethin
@Arniox
@Arniox 6 жыл бұрын
How would you carry over textures into final mesh? I want to do this for a bunch of trees to make them lighter weight and the textures break it so hard.
@CraigPerko
@CraigPerko 6 жыл бұрын
If they're the same tree over and over, use GPU instancing instead. If there's only a few hundred of them, set them to static and let Unity handle it. But if you still need to do this, there's no reason the "textures" can't carry over. Just assign the same material to the new meshrenderer.
@julorapido
@julorapido 2 жыл бұрын
BELLISSIMO
@jarinusgermeraad6328
@jarinusgermeraad6328 7 жыл бұрын
Hello there! First of all, thanks for this video, it has taught me a bunch of stuff and has inspired me as a newb Unity user! I got the mesh combining to work perfectly fine (using Matrix4v4.identity instead of doing anything to my parent transform), but I need the meshes to be split. The reason for that is that I'm combining tile meshes into one mesh, but those tiles are not necessarily connected, so they're effectively tiles on separate planes. What I would like to be able to do is apply textures per plane, thus I would need the mesh to be subdivided into those planes or accessible per plane. Could you give me some tips on the smartest way to do this? You can also message me if you have any questions about my situation, as I'm using it for a grand procedurally generated environment.
@CraigPerko
@CraigPerko 7 жыл бұрын
In general, you can usually get away with using submeshes: answers.unity3d.com/questions/312492/submesh-creation-from-script.html Each submesh is its own material.
@jarinusgermeraad6328
@jarinusgermeraad6328 7 жыл бұрын
Alright, thank you!
@yetojesse
@yetojesse 7 жыл бұрын
Hey. hope I'm not too late for a reply. I made a mesh out of a small obstacle course I made. (stairs up, fall through hole, walk a few steps, done). Problem is, it falls through the terrain when I try testing it. Adding a box collider to the parent helps against falling, but of course makes it impossible to enter.
@CraigPerko
@CraigPerko 7 жыл бұрын
Meshes and colliders are different things. You'll need to figure out how you want to do colliders, but in general, you don't want to have one giant mesh collider.
@rafaelcorrea7959
@rafaelcorrea7959 8 жыл бұрын
Craig, Quick question. is it worth to combine meshes of things that have a "short life"? I'm making a civilization game, and I'm wondering if the visual feedback from selecting tiles would be worth to combine into a single mesh.
@CraigPerko
@CraigPerko 8 жыл бұрын
+Rafael Corrêa Probably not? The cost of combining is really high.
@RoseWoodKitty
@RoseWoodKitty 5 жыл бұрын
I know this video is kinda old but im running into an issue where its not doign all of the meshes that need to be combined, its gtting a bit over a quarter of them before giving up, there arent any errors showign up and its just being kidn of weird, Theres also alot of tris being randomy created. any idea as to what maybe happening?
@ming454
@ming454 Жыл бұрын
I have an error CS0029: Cannot implicitly convert type 'UnityEngine.MeshFilter' to 'UnityEngine.MeshFilter[]'...
@CraigPerko
@CraigPerko Жыл бұрын
You're passing it an object and it wants an array of objects.
@JiosX
@JiosX 4 жыл бұрын
Hello. I know I'm a bit late but what if I want to put like 500 cubes and combine them together using this code BUT when one of it is hit by an explosion, only the hit one will be removed? Is that possible?
@CraigPerko
@CraigPerko 4 жыл бұрын
Look into voxel rendering.
@EZboyrocks
@EZboyrocks 5 жыл бұрын
Thanks so much!
@DriitzzCabal
@DriitzzCabal 7 жыл бұрын
question can you do the same for BoxCollider2D ? you see , I spawn my GameObject based on a picture that find pixels color and apply different gameobject to them , then i give them a boxcollider2d for the floor , platform etc . but the issue now is since they are individual boxcolliders they have "bumps" into them when i move around and also " 455 " boxcolliders ... instead of " ~ 12 if they were merged ".
@CraigPerko
@CraigPerko 7 жыл бұрын
Not as "BOX" colliders. Those have to be boxes. You could use a 2D mesh collider, though. Not sure if there's an included way to create a mesh based on boxes: if you have to do it yourself it gets pretty mathy.
@cloud99456
@cloud99456 7 жыл бұрын
Great tutorial! I'm running into one problem though. I have clusters of "rock" meshes set up in 3 locations on my map. Pretend the 3 locations are like the 3 vertices of a triangle. When I run your scripts and the new "combined mesh" is created, a weird mesh line is created connecting the 3 clusters of rocks I have located at the 3 vertices of the imaginary triangle. I hope I was able to explain the issue. Any idea on how to fix this?
@CraigPerko
@CraigPerko 7 жыл бұрын
My guess is that you aren't using this technique, because that sounds like triangle drift. That should only happen when you are doing it manually and forgetting to offset the triangle indexes.
@bitxo8620
@bitxo8620 5 жыл бұрын
Should i use it for Marching Cubes Algorithm?
@CraigPerko
@CraigPerko 5 жыл бұрын
In general, you should be building the mesh vert by vert for the marching cubes algorithm. This is a very specific method of combining meshes that's rarely useful.
@vladsamonin9794
@vladsamonin9794 6 жыл бұрын
Thank you for the tutorial. So how we can set a color to the Combine Instance Material?
@CraigPerko
@CraigPerko 6 жыл бұрын
You can either set up a material with the right color and then assign it, or use a MaterialPropertyBlock.
@vladsamonin9794
@vladsamonin9794 6 жыл бұрын
Thank you for the fast reply. The way I plan to use it is in runtime (MonoBehavior) mode. There are hundredth of objects created and each of them contain a different colour. I can get the color by doing filters[i].GetComponent().material.color But I have no idea how to assign the corresponding color into the main mesh. All I have is a pink mesh. I guess I can apply one color to it. But that's now what I would like to do. Here's screenshots: 1) What I have after applying the MeshCombiner. prntscr.com/jz9e27 2) The goal to have this (Currently each cube is it's own gameobject): prntscr.com/jz9dr3 Is there any other advices? I tried to use MaterialPropertyBlock, didn't work for me.
@CraigPerko
@CraigPerko 6 жыл бұрын
My guess is that the MeshRenderer you're putting your mesh into doesn't have enough materials in it. You only get the flat purple color when the MeshRenderer doesn't have any materials.
@CraigPerko
@CraigPerko 6 жыл бұрын
However, that said, you can't assign one material to all the cubes and have it look like that, not unless you're doing vertex color trickery. In general, that sort of look is done either by UV mapping, vertex color, or a shader with a global Z axis color gradient.
@vladsamonin9794
@vladsamonin9794 6 жыл бұрын
Yeah, you right. So I added the material into MeshRender. However still can't assign the corresponding colour to the cube object. I tried to use the vertex colour code but it just creates a gradient. Code: prntscr.com/jzap16 Output: prntscr.com/jzap80 Desired Output: prntscr.com/jzapgm UV map wouldn't work since I don't know the colors of cubes before they generated. It's representation of data generated randomly. Is there's anyway somehow to add all these colors when we generate the final mesh? Or in worst case scenario access the final mesh and add to each of the cubes the appropriate color?
@MegaNerevar
@MegaNerevar 8 жыл бұрын
Please provide a way to make a circular hole in a mesh, either on the outline or anypart of the mesh..
@CraigPerko
@CraigPerko 8 жыл бұрын
It's not easy at all.
@MegaNerevar
@MegaNerevar 8 жыл бұрын
will it be possible with a vector graphics toolkit ? like SVG importer or Vector Shapes from the asset store ? I want to generate procedurally generated terrain (2D) that is also destructible by projectiles..
@CraigPerko
@CraigPerko 8 жыл бұрын
Well, 2D terrain isn't so hard, just paint some alpha=0 pixels wherever you need to see through it. Collision detection against it requires checking the pixels, though.
@marcrem
@marcrem 7 жыл бұрын
Can I use this to then save the combined mesh as a prefab as I would normally do in the editor? I would then instantiate / re-use the combined mesh in my scene.
@CraigPerko
@CraigPerko 7 жыл бұрын
You can, but it requires some finagling.
@justloveandpeace4010
@justloveandpeace4010 6 жыл бұрын
Thanks man you are the best
@JJE990
@JJE990 4 жыл бұрын
Good tutorial but I noticed something. I have a C++ background. When incrementing or decrementing a value in a for loop, it is better to use PREFIX operators rather than POSTFIX operators, e.g. ++i (prefix, slight performance benefit and safer) i++ (postfix, slower and not as safe) I'm not going to go into detail as to why, the internet has the answers, but it's better to use prefix and to get into that habit. Btw it's not a criticism, it's something not a lot of people know about. There are certain times where postfix is needed and better but usually that's not the case
@bibib8583
@bibib8583 5 жыл бұрын
one question, when the new mesh is turned into a prefab, the mesh filter shows none in the inspector? is that supposed to happen?
@CraigPerko
@CraigPerko 5 жыл бұрын
Combining meshes don't automatically save the created mesh to assets, although it won't mysteriously vanish unless you create it in play mode and then hit stop. Saving assets is another topic, and not too hard of one, feel free to search on that topic for those instructions.
@aleksadjordjic1631
@aleksadjordjic1631 7 жыл бұрын
Just one question before i try to do this. Will it increase the performance of my game, i currently have a city with over 1000 objects (probably more) and my FPS is 25-30 . Will this help optimizing the game by doing this ??? Thank you :)
@CraigPerko
@CraigPerko 7 жыл бұрын
If it's the same meshes over and over, use GPU instancing or static batching instead. You can find a GPU instancing tutorial on my channel.
@aleksadjordjic1631
@aleksadjordjic1631 7 жыл бұрын
Ok , thank you , i was wondering what was that option "GPU Instancing" , also do you know if it is possible to convert Unity .prefab in to a 3D file , like .fbx or .blend ??? Thank you , and WOW you responded really fast to this comment :D
@CraigPerko
@CraigPerko 7 жыл бұрын
Perhaps, I've never tried. Normally a prefab is not a mesh, but a bunch of monobehaviours that refer to a mesh.
@Levente20
@Levente20 5 жыл бұрын
i have a big cad file imported in my scene, i got a tire with tiresidwall together as one mesh, but in the 3ds max its seperate element. In unity its combined as one mesh, how can i detach the sidewall from the tire?
@CraigPerko
@CraigPerko 5 жыл бұрын
Ideally you should re-export it as a separate object. Doing it in Unity is a pain in the ass and involves manually walking every face.
@visanmadalina2482
@visanmadalina2482 6 жыл бұрын
Hi! I am working on a tile based game. I need to combine multiple tiles into one chunk (single mesh). Will i be able to work with the tiles after that ?
@CraigPerko
@CraigPerko 6 жыл бұрын
That's a complicated question. You can technically edit the UVs of the verts, but I don't think you want to... so, "no, not easily".
@havyn88
@havyn88 6 жыл бұрын
@Craig Perko Thanks for the answer, i got the code working but it didn't fit my project. Do you have any advice on batching materials of large quantities of Objects? I'm trying to spawn 20,000 cubes, and the objects must be interactable with the player. I tried GPU instancing, but the player character simply passed through the items without affecting it.
@CraigPerko
@CraigPerko 6 жыл бұрын
You're talking about voxel techniques. That's a complicated field.
@havyn88
@havyn88 6 жыл бұрын
I was specifically told to use batching of materials, but the objects are not stuck together, and the batches is like 33k.
@CraigPerko
@CraigPerko 6 жыл бұрын
I think you might be using some unusual terms. There are a few things you could mean. The materials are not per-object. One material can be referenced by thousands of objects. Static objects will batch automatically, or you can turn on instancing to really batch them... but that won't help you to create colliders.
@havyn88
@havyn88 6 жыл бұрын
the setup creates clones of one of the objects, and all objects have the same mat x20000. I tried toggling instancing but fps actually got worse.
@NeonTheCoder
@NeonTheCoder 8 жыл бұрын
My childs have multiple materials assigned and anything besides the main material is not saved to the combined mesh so I end up having holes in the mesh for no reason.
@NeonTheCoder
@NeonTheCoder 8 жыл бұрын
Just to be clear I don't need this new mesh to render correctly, as I only need this new mesh for a whole collision instead of parts. so I only need the filter, which I got to save to an actual model as an asset but the model is broken as if it has multiple materials it just deletes any part of the mesh with anything but the first material
@CraigPerko
@CraigPerko 8 жыл бұрын
Yeah, I think I mentioned that multiple materials have to be done carefully. There's a materials array in the MeshRenderer you'll need to use, but that won't work unless the submeshes are being combined correctly, and I don't know if that's done automatically.
@NeonTheCoder
@NeonTheCoder 8 жыл бұрын
Well I think I am close to getting it, but for some reason I am getting an out of range error, I made it so I iterate through the filters then in that for loop I made a loop that iterates through the submeshes and added each sub mesh as a separate combiner, it should work but for some reason this error pops up. pastebin.com/rh4Ts4Q4
@NeonTheCoder
@NeonTheCoder 8 жыл бұрын
the exact error is array index is out of range, and it only says the error when It's done iterating, so right before it tries combining the mesh but the error points to the last combiner[a].subMeshIndex that is set instead of the combine command
@CraigPerko
@CraigPerko 8 жыл бұрын
I'm sorry, I don't know what the problem is, but it sounds like you might have a logical flaw in your code. I don't remember having any similar problems when I did similar things. For example, make sure each combiner is pointed at a mesh with the right number of submeshes. If a mesh doesn't have that many submeshes, don't create a combiner for it.
@cfactorygames
@cfactorygames 5 жыл бұрын
Do u know a way to descombine a mesh? I have a mesh with 2 objects inside and I want become in two game objects each!
@CraigPerko
@CraigPerko 5 жыл бұрын
You have to crawl all the edges and do it manually. It's a pain.
@cfactorygames
@cfactorygames 5 жыл бұрын
@@CraigPerko I need it procedural in runtime
@CraigPerko
@CraigPerko 5 жыл бұрын
@@cfactorygames You can do it procedurally during runtime, but you need to program it to do it manually. It's a pain in the butt.
@jeromej.8726
@jeromej.8726 6 жыл бұрын
Any clue as to why it isn't working in runtime? I'm assuming it might have something to do with the sharedMesh but I haven't been able to figure it out yet. When trying it out in runtime, it just ignore one of the children (or it seems to, anyway) but the vertex count jumps from 60k to 270k somehow.
@CraigPerko
@CraigPerko 6 жыл бұрын
I'm not sure. I think maybe a few things have changed a little in the past two years.
@amoineau
@amoineau 6 жыл бұрын
If you ever find a solution I am highly interested !
@LeonardoSilvaHavelock
@LeonardoSilvaHavelock 8 жыл бұрын
So if i have an character selection and the user selected one, could i use this to render an mesh in a empty object ?
@CraigPerko
@CraigPerko 8 жыл бұрын
There's no reason to do that, just use a normal MeshRenderer/MeshFilter, and switch which mesh is in the filter.
@Todorv1
@Todorv1 5 жыл бұрын
I have 34 * 120 cubes and i wanted to use your code to stop the "lag" or what ever its called when your game doesn't run smooth. But it turns them into a (probably) 30*10 looking blocks. Why is this happening ?
@Todorv1
@Todorv1 5 жыл бұрын
If anyone has the same problem just add finalMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
@CraigPerko
@CraigPerko 5 жыл бұрын
@@Todorv1 TBH, I don't recommend merging cubes. I recommend turning on GPU instancing and marking them as static objects.
@swissmycheese
@swissmycheese 5 жыл бұрын
What is this house building tool?
@EDIshames
@EDIshames 8 жыл бұрын
Hey I have a problem, I made it up to the 7:10 mark, Unity gives me an error "cant convert type Unity.Engine.MeshFilter to Unity.Engine.MeshFilter[]" I understand what it means by that but for some reason it worked for you. I copied everything you did word for word. Any suggestions?
@CraigPerko
@CraigPerko 8 жыл бұрын
+EDIshames You forgot an "s" in "GetComponentsInChildren"
@EDIshames
@EDIshames 8 жыл бұрын
+Craig Perko correct, thanks a lot. Still have a few issues here and there but I get the gist of it. Another question though. What if I combine all these meshes in my 3D application before I bring it into Unity? Wouldn't that achieve the same result?
@CraigPerko
@CraigPerko 8 жыл бұрын
Yes! This is mostly useful when you don't know what meshes you're going to need to combine, or you want to be able to adjust how the pieces are placed without going back to Blender. But if you're comfortable in Blender and don't have any advanced needs, do it in Blender!
@WoodCat
@WoodCat 5 жыл бұрын
Thanks!
@zedgamedev
@zedgamedev 6 жыл бұрын
Can i have multiple houses at different locations using 1 mesh?
@CraigPerko
@CraigPerko 6 жыл бұрын
Of course. Just put the one mesh in several MeshFilters on GameObjects with MeshRenderers. Create some normal cubes and take a look: those are all the same mesh.
@homeslice3964
@homeslice3964 5 жыл бұрын
Just skip to 3:00
@sebbes333
@sebbes333 6 жыл бұрын
Use a zoom function, I can't see anything of the code on my phone
@jstuffss
@jstuffss 6 жыл бұрын
solution: dont watch i ton a phone, when you're using a pc to program why would you watch it on a phone? or expect everyone to have to deal with his zoom function so that one person can rad it on a phone. cmon
@Levente20
@Levente20 5 жыл бұрын
and how do you detach meshes?
@chocogreen1
@chocogreen1 6 жыл бұрын
Hi there! So... I've been following exactly what you have done in the video, but unity jumps out an error saying: ¬Combine mesh instance 0 is null. UnityEngine.Mesh:CombineMeshes(CombineInstance[ ]) ¬>>>UnityException: Transform child out of bounds WorldGeneration.Combine(at Assets/Script/World Generation/WorldGeneration.cs:169)
@CraigPerko
@CraigPerko 6 жыл бұрын
This is your problem: if(meshFilters[i].transform == Quads.transform) { continue; } It's leaving a hole in your array.
@CJBurkey
@CJBurkey 8 жыл бұрын
Thanks :D
@moshelinke2979
@moshelinke2979 6 жыл бұрын
error CS0029: Cannot implicitly convert type `bool' to `MeshCombiner'
@CraigPerko
@CraigPerko 6 жыл бұрын
That's a fundamental error in your code, maybe you're using the wrong variables or something.
@ShiftedStriker
@ShiftedStriker 3 жыл бұрын
I saw how long the vid was and now im scared that im going to get a single thing wrong and ruin it
@rafaelresende5413
@rafaelresende5413 5 жыл бұрын
I need to create a descombiner! Do u know how?
@CraigPerko
@CraigPerko 5 жыл бұрын
You need to crawl each edge and compile them manually.
@jiazq
@jiazq 8 жыл бұрын
awesome! have subscribed you !
@juliatran2923
@juliatran2923 8 жыл бұрын
My handle isn't showing up in scene view. :(
@EXHOUL
@EXHOUL 4 жыл бұрын
Sometimes the object to which to assign the handle will place it really far away due to its transform parameters. You can always create a new empty child of one of your meshes to combine (so it will have proper transform parameters) and move it so it is parent that has the handle. The handle will appear there for sure :)
@purel2449
@purel2449 5 жыл бұрын
Combining materials ??
@CraigPerko
@CraigPerko 5 жыл бұрын
You can't combine materials, and there's not too much reason to combine meshes with different materials. It's only useful in very specific situations in the first place, since Unity's gotten pretty good at automatically batching meshes.
@theairaccumulator7144
@theairaccumulator7144 6 жыл бұрын
Woo! W?
@ep1417
@ep1417 2 жыл бұрын
There are much better ways, and this code is not the best way to do it. Doesn't show you how to search children for materials and preserve them.
@Amazingg1100
@Amazingg1100 5 жыл бұрын
Or you could just abstract yourself of all this stuff by importing this free asset, which is doing this with 3 simple clicks. assetstore.unity.com/packages/tools/modeling/same-material-static-mesh-combiner-139565
@INRamos13
@INRamos13 8 жыл бұрын
Shit I actually needed to export the result mesh... Help, anyone? It's pretty urgent...
@CraigPerko
@CraigPerko 8 жыл бұрын
Exporting it into Unity is pretty easy - just pick a prefab and set the SharedMesh to it. Exporting it as a standalone FBX file is a lot harder. Easiest way is probably to edit the mesh of the saved prefab by double-clicking, if Unity still supports that.
Creating in Unity #6: Advanced UnityEventing
12:26
Craig Perko
Рет қаралды 2,3 М.
Não sabe esconder Comida
00:20
DUDU e CAROL
Рет қаралды 64 МЛН
1, 2, 3, 4, 5, 6, 7, 8, 9 🙈⚽️
00:46
Celine Dept
Рет қаралды 36 МЛН
How Strong is Tin Foil? 💪
00:25
Brianna
Рет қаралды 61 МЛН
The New "AI Minecraft" game everyone is talking about right now.
8:16
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 724 М.
Unity Performance Tips: Draw Calls
4:24
Lofi Dev
Рет қаралды 195 М.
I Wish I Had Known This Before I Started Unity Game Development...
11:11
The Most Impressive Scratch Projects
11:00
DenshiVideo
Рет қаралды 5 МЛН
Increasing FPS by combining meshes in Unity3D
8:47
Tudvari
Рет қаралды 51 М.
Import Real World Terrain into Unity 3D- New video in the description below!
15:34
Unity 3D - Rigidbody VS CharacterController [UnityQuickTips]
18:56
Master Indie
Рет қаралды 159 М.
How To Slice Meshes In Unity
4:43
Tvtig
Рет қаралды 89 М.
AI Learns to Play Tag (and breaks the game)
10:29
AI Warehouse
Рет қаралды 4,2 МЛН
REAL MADRID 0 - 4 FC BARCELONA | RESUMEN LALIGA EA SPORTS
3:35
LALIGA EA SPORTS
Рет қаралды 15 МЛН
Have fun!
11:55:00
ZEN MAHJONG Official
Рет қаралды 2,5 МЛН
[RU] BLAST Premier World Final 2024 - День 5
3:45:53
RLG PARI RU
Рет қаралды 199 М.
BLAST Premier World Final 2024, GRAND FINAL: G2 Esports vs Team Spirit
5:3:53