So I randomly thought of making some armour system for tanks as a fun thing to do but then of course not many tanks have 90 degree armour so then that’s where the relative armour thickness comes into play.
I can’t figure out the impact angle at all I don’t use Vectors much and that is most definitely the solution, I’ve tried trigonometry but that wouldn’t work, literally all I need is a way to figure out the impact angle shown above, any help is appreciated.
Also the direction of impact would be different every time it wouldn’t be a straight line.
You can get the angle between the normal vector and the velocity of tbe bullet projectile.
Explanation:
Normal vector is the red arrow labeled n with an arrow on top as it is a vector.
Velocity is the blue arrow, this assumes the bullet is facing in the direction it is traveling which is most of the time true.
Getting the angle theta (red circle with the slash in the middle) between them is the acos and dot product part of the script (vector trigonometry)
Then math.pi/2 or 90° is subtracted to get angle of impact as the surface of the plate is perpendicular to the normal vector. This is known as complemetary angles in trigonometry.
local impactPoint = script.Parent.ImpactPoint
local armourPart = workspace.Part3
local norm = armourPart.CFrame:VectorToWorldSpace(Vector3.FromNormalId(Enum.NormalId.Front))
local aoi = math.pi/2 - math.acos(-armourPart.Position:Dot(impactPoint.AssemblyLinearVelocity, norm))
I currently have this but no matter what I change the AOI output is always 0deg, meaning the acos is 90.
I’ve changed many things but to no avail, is there something obvious I’m missing?
I tried that still doesn’t change much either makes it nan or just 90.
Edit: The Velocity is 0 which makes the Unit return NaN
Edit 2: I fixed it, thank you a lot for your help.
Edit 3: Everything works normally except from when the armour is angled at 90 degrees it goes to a ridiculously high number, as expected using tangent instead fixes this and gives an accurate result, how would I differentiate these and tell the script to use tangent or cosine?
For the big angle problem one of the possible reasons is that it will measure the angle phi instead which is the green label. I think you can just counteract it by seeing if the angle is more than 90 degrees if so then you can minus 90 degrees.