- Home /
How to simulate bullet penetrating a cube?
Hello, How exactly will I go about to create simulation in which a bullet (with huge velocity) penetrates through a "wall's bricks" (cube or a lot of cubes stacked together)? The bullet may or may not go completely through the wall's bricks. Thanks
Even though it's just a couple of sentences this is an ENOR$$anonymous$$OUS question in terms of scope and ambiguity. Please be more specific.
Forgive me for sounding ambiguous. I wish to replicate a real life bullet being shot through a wall as realistically as possible. What I am envisioning is this: attach a rigid body component to a bullet mesh, give it an initial velocity towards a wall (for starters, just a cube), and make it "breakthrough" the wall; that is, it should leave a small hole in the wall, be deflected a bit, and at the end be stuck in the middle or somewhere inside the wall's model. I hope this helps clarify what I am ai$$anonymous$$g for. If I figure out how to do it with one bullet, I will replicate it so as to have multiple bullet being shot at that wall and penetrating it as I described above.
For leaving a hole you can either Instantiate a small plane with a texture on it. If you really want to create a hole and not only make it look like, you would to have to alter the mesh during runtime which is quite advanced. For deflection you could go with snell's law calculating the new velocity from the old one and the mesh's normal. The slowing effect would be the most simple. All you have to do is reducing the bullet's velocity as long it is inside of the cube.
Thank you for your reply. How would you suggest I go on about altering the mesh during runtime? I wish to simulate an actual hole not just texture.
Checkout this post. Also, checkout object.$$anonymous$$esh. But be warned, altering meshes at runtime is not for the feint of heart.
Additionally, I'd recommend you go with the Find_1t's suggestion of simply placing a 'decal' where the bullet hit. You could use a single triangle (3 verts and one poly) to map the texture on and it would be a lot cheaper than adding several new verts and possibly losing your batching ability on those objects.
You could still simulate what would happen to the bullet like whether it would penetrate and still do damage on the other side or whatever else.
Answer by dubbreak · Feb 14, 2013 at 07:37 PM
Megafiers has some physics based modifiers they are adding. I didn't see anything like this, but you could touch base with them.
Covering how to do it yourself is beyond what can be answered here. What you are asking is beyond plenty of people with compsci degrees. It's huge. I mean even defining the materials so you can calulate how it's deformed and destroyed is a big task (and I assume would take some physics background.. my one uni physics course is failing me on what variables would be needed). I'd also be worried about performance (though since I'm not sure on how bad the calculations are it might be fine especially if you aren't dealing with too many vertices).
My question is: Why do you want to do this?
With the blocks and the suggestion Lockstep made you can have a pretty realistic physics simulation and just take on a texture (like ultimate fps does) and it's good enough for games. If we know more about why you want to simulate and actual hole then maybe you can be pointed in a better direction.
If what you really want is to do physics simulation, then there is other software more suited to it than Unity that should take care of most of it for you.
The reason I am doing this is that I wish to know to what extent I can push the accuracy and performance tradeoff that differentiates video game development from scientific simulations. Basically how accurate can we get while still getting a reasonable visual simulation.
Real time simulation? You can always use unity to visualize data from other sources.
That's was what I had in $$anonymous$$d from the beginning. I just wanted to know whether unity could assist in the simulation by simulating the less important parts. From the looks of it, it doesn't seem very likely.
Well it's doable, just not without writing code. A lot of code. $$anonymous$$aybe someone else will pitch in with something more. Though you could contact the guy who wrote megafiers to see what he thinks of simulating what you're trying.
Your answer
Follow this Question
Related Questions
Penetration weapon needs to find all objects it passes through 1 Answer
Bullet Penetration 1 Answer
Simple Raycast Penetration 1 Answer
How to Create Bullet 2D 0 Answers