Hello, im trying to make a tank armor simulation like in War thunder, when you hit somebod with a tank round. Im trying to achieve this using raycasts and due to that, i don’t know how to script the relative thickness calculation of a armor piece. I have tried many times, but it always has ended in failure.
I only know what i needs to happen:
Fire a ray and detect the part.
Change armor piece’s thickness in stud to millimeters.
Take the thickness, angle of attack and angling of the armor piece to calculate the relative thickness.
(Here lies the problem because, i don’t know how to script this relative thickness calculation)
Check if the shell (raycast) pentrates the armor.
So if anybody is willing and able to help me on this in any way possible, it would be much appreciated.
You don’t really need to calculate studs to millimeters for this, just figure out how thick in studs the armor is and base your penetration calculations on that.
Look at the angle the raycast hits the Part at.
For example if you have a 38.67 degree difference with a .3 stud thick Part:
Sine of the angle = the thickness of the part / the hypotenuse length.
for the conversion multiply both sides of the equation to get the hypotenuse on the top. This cancels out the hypotenuse on the RH side of the equation (hyp/hyp = 1)
hyp. * sin(angle) = thickness
to get the hypotenuse by itself on the LH side divide both sides by sin(angle). This cancels it out on the LH side because [sin(angle) / sin(angle) =1)
This gives you
hyp = thickness / sin(angle)
so if you have a .3 stud thickness
hyp = .3 / sin(38.67)
hyp = .3 / .6
hypotenuse = .5 studs
This can be checked by knowing that a 3x4x5 stud triangle (or .3x.4x.5 studs) is a right angle triangle with an angle of 38.67 degrees.
This means the shell distance travelled through the .3 stud thick Part would be .5 studs at 38.67 degrees.
If you do the same calculation for a 1 stud thick Part hit at 90 degrees (a direct shot you get:
hyp = 1 / sin90
hyp = 1 / 1
hyp = 1 stud