- Home /
How could I cut a mesh into two pieces with code?
I want to do something that seems to be simple but is proving difficult to find an answer to. All I want is to be able to cut a cylinder mesh straight into two pieces dynamically in real time using code. The cut does not have to be diagonal or anything, I just want it to be a straight cut at the point where the mouse is on the object. I know that there are a lot of assets out there for cutting objects but they are all very complicated and kind of overkill for what i want to do, because I don't require any weird angled cuts, and i also don't want a system like fruit ninja where you drag the mouse to determine the cut. I just want to be able to have a cylinder mesh in my game and click on it with my mouse on certain spots and have it cut straight in half at those locations. This is hard to word and I hope somebody can help me out, because I am just at a loss of where to start with the code.
Thx
Cutting a mesh can be a difficult thing. Assu$$anonymous$$g there are no texturing issues, it is far easier to replace a single cylinder with two cylinders resized to represent the cut.
Answer by SunnyChow · Jan 20, 2014 at 02:54 AM
I think it will be easiest if you create two chopped model in 3d editor and then replace the original cylinder with them.
Otherwise you will have to do lots of calculation to cut a 3d model to two. Have you written any script to modify mesh? First you have to separate the mesh's vertices into two arrays. Then you have to create the two triangle arrays depending on the original mesh and those new vertices arrays.
Or you can buy plug-in in unity asset store
Your answer
Follow this Question
Related Questions
Cutting a Mesh Into Smaller Pieces 5 Answers
Detecting the subobject of a mesh 1 Answer
Can I stop my player from coming to a stop when colliding? 2 Answers
Vehicle Parts - Bones or Separate Objects? 2 Answers
Resizing one mesh to fit another mesh. 0 Answers