- Home /
How to "cut" a piece of glass in more parts??
Answer by Anxo · Jun 02, 2011 at 09:17 PM
You would need to have the glass in full and the glass in pieces. you can attach rigidbodys to the glass in pieces and put it into a Prefab.
Then when you want to break the glass, you would delete the in tact one and replace it with the broken glass prefab like so.
BrokenGlassPrefab : GameObject;
function OnCollisionEnter(other : collider){
if(other.gameObject.CompareTag("head"))
{
var BrokenClone : GameObject = Instantiate(BrokenGlassPrefab, transform.position, transform.rotation);
Destroy(gameObject);
}
}
put that on the in tact glass and place the prefab in the broken glass variable.
yeah, u're right, but if the glass pieces fallen on the ground are hit another time, how can I break the broken glass??
same way, have pieces of the pieces as prefabs and as they hit the object tagged "floor" spawn the new little ones. There is no Fracturing system in unity so it has to be faked.
What your talking about could get pretty heavy but I am looking forward to see it if you complete it.
You could make the smaller pieces more generic ins$$anonymous$$d of matching the shape, that would allow you to use the same object multiple time and you could just run a for loop to spawn 5 small broken pieces from every larger pieces that hits the floor and so on.
Answer by DaveA · Jun 03, 2011 at 12:21 AM
Crazy idea, I've not tried it, but what if your glass consisted of many triangles (like the standard Plane object), and when hit, you'd edit the mesh to split it into several smaller meshes. Like say you wanted 10 shards in the result, assign each triangle a random number from 0 to 9 and create 10 new meshes, copying the verts and faces to those meshes. Some of those might contain several triangles, which, when hit again, would do the same type of thing.
Your answer
Follow this Question
Related Questions
Glass break effect 2 Answers
Make Wall/Glass Damaged 1 Answer
Having trouble making transparent glass 1 Answer
How do I stop seeing through models by glass windows? 1 Answer
Simulate polarized glass and projectors? 0 Answers