(Sorry for my english i’m using a translator)
Hello, I’m working on a gun that create bullet holes using raycast, it works pretty well in all types of part but when I shot in a place that already has a bullet hole the bullet holes stack into each other:
(Model isn’t mine)
And the solution i found to this is:
-- Changes the normal axis for the Collided bullet part normal axis and keeps the another axis
if Raycast.Normal == Vector3.new(1, 0, 0) or Raycast.Normal == Vector3.new(-1, 0, 0) then
-- Normal axis is X
BulletPart.Position = Vector3.new(CollidedBulletPart.Position.X, BulletPart.Position.Y, BulletPart.Position.Z)
elseif Raycast.Normal == Vector3.new(0, 1, 0) or Raycast.Normal == Vector3.new(0, -1, 0) then
-- Normal axis is Y
BulletPart.Position = Vector3.new(BulletPart.Position.X, CollidedBulletPart.Position.Y, BulletPart.Position.Z)
elseif Raycast.Normal == Vector3.new(0, 0, 1) or Raycast.Normal == Vector3.new(0, 0, -1) then
-- Normal axis is Z
BulletPart.Position = Vector3.new(BulletPart.Position.X, BulletPart.Position.Y, CollidedBulletPart.Position.Z)
end
But this only works with parts rotated in perfect angles and with straight surfaces, if the ray hits a bullet hole that were in a cylinder then the bullet holes will stack in each other.
My question is: how can i get the biggest or smallest number of raycastresult.Normal?
Because the biggest (or the smallest) is the normal axis, but i can’t think how can i get this number