Procedural Destroy in Unity - Lazy Tutorial
HTML-код
- Опубликовано: 28 сен 2024
- I fell in love with lazy tutorials by IanHubert. These one minute tutorials show how to do something amazing for people with mid range knowledge. So this is my turn on unity.
Have fun! Advanced stuff like many requested!
Lego Series will continue on saturday.
Script: gist.github.co...
Inspired by IanHubert: / @ianhubert2
(give him a sub)
#ditzelgames #lazytutorial
You lost me when you put back the knife. We needed that.
that's not a knife. THIS is a KNIFE
😂😂😂
@@studioshitaketakashita7093 Hey, Crocodile?
Are the god sent you to help Unity dev of something? Because after Unreal releasing Chaos you make a simple clean yet advance procedural destruction like this!
Unity should hire you to do advanced stuff like this!
Dude, I like the format and presentation. Most Unity content on YT feels like the author is hand-holding or teaching kids, because there will always be a _vastly_ larger number of beginners with something difficult and catering to them gets the most views. So most videos about Unity are essentially un-watchable for a professional developer or you have to run them at 1.5 or 2x playback speed and skip through em, lol. Autoplay landed me here and I began listening and really enjoyed how quick and to the point the video ran, only 1 minute long! :D
Awesome guide, the world has been needing something practical like this forever now
0:58 That part hits different at 2024 💀
Thomas Matthew Crooks: "I watched this one video from the internet..."
This is simply one of the most amazing tutorials I've ever seen. And the information is extrmeely useful, very confusing topic too.
That's crazy I was just watching IanHuberts tutorials. Make more like these, they are great!
Finally, somebody who bothers to explain how mesh destruction actually works, instead of copping out and pointing me to an asset store. 👍
Nice! Please more of this, although I can imagine, those are pretty hard to produce.
Yes, they are. It takes more time to produce less
This is absolutely phenomenal, I would love to have a better understanding of how this works. I hope you make a tutorial series for someone with a beginners understanding of unity to explain this aspect of the unity engine. Also is this code free to use?
I recommend to learn the basics of unity before doing more complex stuff
Instructions Unclear: Cut monitor in half with knife
Ohhh maaan, i love you! Thanks 🙏
Awesome tutorial approach and result!
Now thats how tutorial should be👍👍👍
Subcribing to you becuase of these lazy tuts😂.
Make more like this
Awesome work man and very greatful for your sharing.
Impressive tutorial. This solution is amazing - and in less than one minute :)
This is genius, but sadly it very lags with cascades more than 1, and if box keep falling and crumbling each piece it crashes the project 😮😅😢
can you please make this video understandable and slow like a teaching tutorial? nothing can be understood with this fast video seems like ads running.
The way u say triangle ! Love the french
Great vid straight to point in just one min. Subbed
With about 9 to 10 segments set as the variable, it worked quite well as a script for destroying a lamp in my game. The only issue is that many of the shards fall out of the world. Most likely an issue with unity physics or how it handles rigidbodies switching parents.
Do I have your permission to use a modified version of your script in my game that may or may not be commercially released if I complete it?
Thank you for this great solution!
How did you limit the segments?
@@Danilo-by1po I think in the script there is an int for the amount of segments it splits into
hey can I use this in my game?
Thanks for the tutorial!
this is cool I once made a similar tool,tool. however it is not applicable to real game application for most cases
because of the amount of CPU time to run the division and re-assemble and the worst thing is memory fragmentation.
It is usable for simple mesh and few cuts.
The worst thing is the usage of the mesh colliderr. If your game doesn't need that. You're fine
Why not using a pool specific to destruction? When the cut are too small, just fade them and then change the mesh with no size (the original is stored anyway, don't destroy it xD), then inactive the game object. So you'll use it later, not so much memory problem and even skip that hellful garbage collector! Now for the generation of fragments, you can do it with other threads (not a huge problem if it's just one or two frames later that you see the mesh being really cut) for the mesh fragmentation. Otherwise, you can also use a compute shader to do that but it's only worth it if the mesh is too huge! But the problem when dealing with compute shader, you will need to use AsyncGPUReadback or AsyncGPUReadbackRequest and those are kinda trikky. It's better to just do some multi-threading for that anyway, because of data latency from the GPU.
@@IkikaeruRaimei That's a great idea, I could use that, thank you!
Inspired by Ian? Nice :)
Funny I was thinking about procedural destroy in Unity today, how to make it.
Does anyone know why the MeshDestroy script sometimes creates objects with a bounds.extents.magnitude of 0?
Griffpath be like:
Very good job I love watching your videos. I have a doubt about the game objects are not destroyed and consume enough memory. What I can do?
Destroy them with a coroutine after a certain amount of time
Lol awesome tutorial!
I can't wait to implement something like that
i am using this when i call the destroy fuc() onTriggerEnter then it will create too much pieces and system is halt ,hang how to control it
MeshDestroy.cs(119,41): error CS1644: Feature `out variable declaration' cannot be used because it is not part of the C# 4.0 language specification
I get this error. Any ideas?
Player Settings > Change to .net 4.0
I got the error message,
error CS1644: Feature `out variable declaration' cannot be used because it is not part of the C# 6.0 language specification
change the script, it worked
At the line 119, change "out var enter1" to "out enter1", and in the same method declare "float enter1;"
do the same thing to "enter2"
how can i make an explosion type hole in a mesh
its not a lazy tutorial if we have to write out the code
A knife will help me cuz i didnt understand a thing )
This is awesome but my computer CPU is literally exploding Unity trying to do that xd
Thank you very much !
any way you can upgrade the script so the different parts created when you destroy the mesh are merged to still be 1 mesh? currently it creates seperate meshes on each destroy which creates huge amounts of batches which make it unplayable... :) thx!
Hello, I would like to use my 3D objects, only when I click to cut the object it sinks to the floor and creates an invisible piece, do you know what it can be?
I used a simple Cube and realised the parts were often a lot smaller than I was expecting. If you switch to the Scene view, can you locate the piece by selecting in the heirarcy and clicking F? I also upped the cascade cuts to about 4 for more pieces. Jumped straight to 25 and locked up my Unity xD. Now I have to look through it, understand it and give it a custom plane, not a random one... Thanks very much for the starting point!
Hey i was just having the same problem, and in my case it wash an issue with the scale of the imported object. Just un check convert units on the import options and adjust the scale by hand.
Hey! Found a fix. Probulderize the mesh and it works like magic! Tools -> Probuilder -> Object -> Probulderize
This is really intersting info. Still the code is not very usable to me: after testing it a bit, it freezes Unity in what seems like a memory leak. Still interesting, though, thanks anyway.
you have to name you Script "MeshDestroy" if you want it to work
Wow
Fun
Do what?!
Hi, any chance you could do a tutorial on spawning enemies with trigger in a 2D game. I am pretty new to game making and have a script that spawns enemies, but, they are invisible!!!! Only know they're there when hit player. I am completely baffled so if you could help I would be eternally grateful. Enjoying your other tutorials, thanks for your efforts :-)
need tutorial plzz how it works
Unity freezes forever if this script is on about 10 object and called at the same time.
Lazy Tutorial? this was way, way way to complicated.
You should have put Nethanyahu and biden at the end instead of trump.
Twiangle
wurth ...
poor trump.
I'm sorry
@@DitzelGames no no no, dont get me wrong, he deserved it.
After seeing IanHuberts Blender tutrorials, i was wishing somebody would do the same for Unity. Keep them coming!
IDK it's not lazy for the creator ...
Haha i did same move :D
Need more tutorials about procedural animation ! Thanks for the good work
It works great with unity objects but with imported models in doesn't work. Can somebody please help?
hey man, thanks for this but is this open source? You have not added a license to the code on github
Thanks for this, algorithm seems useful ...if you want more inspiration for quick tutorials, here is another author: Royal Skies LLC (Blender tutorials)
i tested out the script and it worked so well! but i have but one simple issue, how do i get the parts to not use gravity in the script? or to copy the stats of the original object?
Edit: i figured it out i did this for the gravity and you can just put in what you want the pieces to weigh
public float mass;
public Rigidbody rb;
//underneath public float ExplodeForce = 0;
//and then you put this part in its own section
void Start()
{
rb = GetComponent();
rb.mass = mass;
rb.useGravity = false;
}
Unity crashed.
When I try to use it, I get this error: IndexOutOfRangeException: Index was outside the bounds of the array.
MeshDestroy.GenerateMesh (MeshDestroy+PartMesh original, UnityEngine.Plane plane, System.Boolean left) (at Assets/Models/MeshDestroy.cs:106)
MeshDestroy.DestroyMesh () (at Assets/Models/MeshDestroy.cs:63)
MeshDestroy.Update () (at Assets/Models/MeshDestroy.cs:27)
did you fix it?
@@salmaanmoosa3103 Unfortunately no, I ended up cutting my meshes in Blender manually, took me a few hours
@@dan.lespect prolly best way to go - or just do destruction animation fbx also in blender. instantiate that exploding body bits anim when Destory.Enemy
Great tutorial tho sometimes it gets laggy and this is not good since I want it for mayor destruction
Thanks buddy *steals code*
not really lol
not working am sad
Could this be used to make destructible rock in a mineing game?
Im going to do evil things with this.
The amount of times I've searched this up haha, thanks g
So thats code....i legit have to right thay?
That Trump move was funny 😂
This is what I needed, thank you very much! Definitely earned a like and sub
I have a question abou this script. I used another cutting script called "ezy slice" before and both the old one and yours have the same weird behaviour. It is working on Unity priimitves like cubes and spheres but not on imported objects. even imported cube objects D: any idea why? greetings Oliver
Have you fixed this?
Have you fixed this?🥲
There is a setting such as read/write in the mesh settings of the imported objects. When you change this setting, the problem will be solved. @@xyt2826
unfortunately not :(@@xyt2826
For future reference, in the Model tab of the imported fbx, you have to set Read/Write Enabled to True, and then Apply and click Open at the top op the options. That worked for me.
Help how do i make the fragments dissapear after so long
Counter then Destroy.object
Haha you’re quite funny!
i think i laughed to hard at trump part lol
COOL!
This is very awesome. Good job! But I have a question, how can I make the broken parts not break again anymore? I need this for a private game but i can't figure it out. If anyone could help me I would be very thankful
If you are still stuck on this, just add a check for a component (create a "dummy" one that will be used to flag objects), or the object's tag (if you are using the tag for something else, use the component method instead) on the game object before attempting to slice it.
There is a code in the MakegGameObject function where this script is added, you can delete it, but there is a problem that the first object that is cut never remains as it is, and since the rest of that object is created as a new object, you remove this script from the main object and you can follow an orientation accordingly. Of course, it's a little late to say this.
I use this script on my models but it`s not working. When i create models in Unity it`s working. How i can fix that?
awesome work =)
Brilliant!
hello can you help me I want to use something like this
DestroyMesh(MeshFilter meshFilter,MeshDestroy meshDestroy){
}
input : DestroyMesh(other.gameObject.GetComponent(), other.gameObject.GetComponent());
Getting Error of null referance of MeshDestroy at this line........... parts[i].MakeGameobject(meshDestroy);
unity lazy tuts.... LETS GOOOOOOOOOOOOOOOOOOOOO
I tried to add a functions for destroying the gameobject after some time delay, but couldn't get it working. Any tips how to implement pls?
i dont know if you're still active, but how do I set the event to happen on collision with a game object like a rocket? I tried but it won't set off the destruction even if it notices the collision
Hi,
Can I use this code in my game ?
You didn't leave a mail adress anywhere...
Regards.
Thank you so much. good luck
"destroy something worth destroying" destroys trump...
I like the way you think
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dose this work for vrchat
1 minute!!!!!!!!
pog
lol
Hello i am new
Great job has been done
Need a hint, slightly changed the condition of destruction (Destroyed when colliding with an object on which a certain tag)
The problem is that it gets destroyed too much, which is bad for performance, sometimes the computer jams, let alone the phone.And the question is, is it possible to somehow limit the number of parts into which an object can be destroyed, For example, the maximum generation of fragments: 100/50/10? ? ?
Or something else for optimization
holy crap this was awesome
*procedural
more
Hillarious, but also awesome! Thanks man!
Great tutorial! Thank you!
[Physics.PhysX] QuickHullConvexHullLib::findSimplex: Simplex input points appers to be coplanar. Does anyone know what this means?
That's a warning. It means that your mesh has no volume in the convex hull. Physics will be inaccurate
@@DitzelGames is there a way to avoid this? with a if statement?
Can you do a more detailed tutorial on this?
The ending couldn’t have been more perfect lol
I don't want to ruin the party, but please work on your pronunciation of Rs. As a non-english native myself, it makes it quite hard to understand you when all your Rs feel like Ws.
Otherwise, good video!