- Home /
How can I recreate tank spalling in my game?
Hello all,
Today, an idea sparked into my mind and I wanted to create a tank simulator similar to War Thunder. I have already started out with the Physics Tank Maker asset from the asset store, but there is one thing that I can't seem to get.
In games like War Thunder, there isn't a HP system or Hit Points. There are modules (like engines and crew members) that you have to destroy to knock out a tank. And the way it happens is when the bullet hits the armor, it will break up into bits and pieces called spall or shrapnel. These hunks of metal are what actually do the damage to the insides of the tank(if the bullet was able to go through the armor). I found this YouTube video showing a simulation of a bullet going through armor:
https://www.youtube.com/watch?v=_1sNSBQdiBo
The problem is I don't know how to implement this to my game. Should I use unity's physics engine or raycast? And how would I?
Answer by SamElTerrible · Oct 13, 2021 at 01:11 PM
Having shrapnel fly around inside the tank to determine how damage is dealt to the inside seems overcomplicated for a game. What I would do is have different colliders on the outside of the tank; and each collider is mapped to an inside element of the tank. E.g. if you hit the collider at the back of the tank, the engine will be damaged, and if you hit the collider around the middle it will hit a crew member.
Okay, I like that idea.
"Having shrapnel fly around inside the tank to deter$$anonymous$$e how damage is dealt to the inside seems overcomplicated for a game."
I don't think I really agree with that. I don't think it is over complicated, I think it is just more difficult. Having Colliders all around the tank wouldn't be that realistic. If I were to shoot the tank from the front, I would only kill the driver or assistant driver. In real life, if I were to penetrate the frontal armor, it the spall/fragmentation would create a shotgun like effect that would destroy/kill everything it hits.
So I was thinking about making a raycast "shotgun" script that would activate when the bullet penetrates. OR use a particles to simulate the spall/fragmentation.
I am trying out the particle system, I got it to somewhat work. But I need the particles to remove child objects. But I can't seem to get it to work.
Totally agree with this:
Colliders all around the tank wouldn't be that realistic
By overcomplicated I meant in terms of scalability. As a developer I normally have to think about ways to 'fake' different effects in order for my project to be optimised.
Of course, having particles with colliders inside tanks would be the most realistic approach (and its a pretty good idea in my opinion). However, its one thing to have just one tank working like this on your PC. Its another thing having several tanks spawning particles which detect several collisions per frame running on a low end Android phone.
I guess it depends on where you want to go with your project. But if you opt for the particle solution, I know you can set your particles to detect collisions on the emitter. Once you have collisions detected then you can do pretty much anything with that information.
"As a developer I normally have to think about ways to 'fake' different effects in order for my project to be optimised."
Well, even though we all try to fake stuff like bullet ballistics. I feel (this is just my opinion) that it sometimes takes longer than just simulating in real-time. And, I also feel a bit tired of those colliders on the side of the tank with some RNG to calculate the damage/hp etc.
So, changing the subject. I encountered an issue: It doesn't seem like child objects can detect or be detected in collisions. And this is an issue because my hierarchy is like:
Main_Body
- Driver
-Assistant Driver
-Turret
-Gunner
-Commander
-Loader
-etc
...and all of the child objects (like crew members) aren't being detected. Is there any way I can make it so that they can be collided and detected with?
Answer by Aj8841 · Apr 12 at 11:54 PM
I think I might have got somewhere:
I took a break for awhile and landed upon Gunner Heat PC on youtube and it inspired me once again.
So i looked up a bullet penetration tutorial on youtube, implemented it, then added a shotgun thing to it so the shotgun pellets would be the spall fragments. I was able to simulate HEAT and AP rounds, but as of right now, you can only see the damage in the editor.
Here is my result: https://youtu.be/BVoMwAx9LqE
code download (github): https://github.com/XSnipinblazeX/TankSpalling
Your answer
Follow this Question
Related Questions
UI text script error 2 Answers
How do I change the speed at which the slider moves? 5 Answers
GameObject not being recognized 1 Answer
How to adress a Transform inside a arraylist that's inside a arraylist. 1 Answer
c# camera PropertyDialog() 0 Answers