I was working on a gun.
Tried to implement a penetrating feature, this happened:
https://media.discordapp.net/attachments/1086580580197609493/1108456221285040228/problemWithPenetrationOfBullet.gif
Not penetrating works perfectly fine.
Yeah, i tried editing my code. Like for the second raycast after penetrating, I used the gun position to start the raycast and little stuff like that which didnt fix the problem.
This is the raycast function
local function createRaycast(blackList , bulletOut, direction, distance)
-- Raycast params
local rayCastParams = RaycastParams.new()
rayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
rayCastParams.FilterDescendantsInstances = blackList
-- Create Raycast and return it
local rayCast = workspace:Raycast(bulletOut, direction * distance, rayCastParams) or {["Position"] = direction * distance}
return rayCast
end
This is how I will make another raycast if the raycast hits a penetrateable object.
local newRaycast = createRaycast(ignore, oldRayCast.Position, direction, newDistance)
bullet.bulletTrail(oldRayCast.Position, newRaycast.Position)
newBullet:Shoot(newRaycast)