Realistic-ish tank armor simulation

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:

  1. Fire a ray and detect the part.
  2. Change armor piece’s thickness in stud to millimeters.
  3. 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)

  1. 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.

3 Likes

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

5 Likes

I got the calculations working but i have another question. How could i take the guns rotation in to account? (Edit: i got it working properly.)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.