Hello,
im attempting to make a sort bullet hole kind of system and its working fine, except dat when the bullet lands on a obj like a wall, the bullethole gets rotated the exact oposite, check the video
Simply said, the bullet doesnt get rotated correctly.
if you know as to why please let me know. The code is:
if RayCast and RayCast.Instance then
local bulletHole = game.ReplicatedStorage.GibBulletHole:Clone()
bulletHole.Parent = RayCast.Instance
bulletHole.Position = RayCast.Position
bulletHole.CFrame = CFrame.new(bulletHole.Position, bulletHole.Position+ RayCast.Normal)
local wc = Instance.new("WeldConstraint", bulletHole)
wc.Part0 = bulletHole
wc.Part1 = RayCast.Instance
game.Debris:AddItem(bulletHole, 63)
end
If so, then you should try rotating the model in the modelling software, if you’re using blender, make sure you’re exporting it with the transform included
In that case, you could multiply the normal, i think you need to multiply it with a vector3, but not sure. Can’t say exactly how to do it, but i think that could work. Maybe try Vector3.new(1,2,1) or maybe add (+) it with Vector3.new(0,90,0)
what could that vector be? I have no idea what a normal even is. I followed a tutorial allong, ik what all the others do but not what a normal is. Might look at the docs.
Putting it inside: bulletHole.CFrame = CFrame.lookAt(RayCast.Position, RayCast.Position + RayCast.Normal);
gives a error, and putting it just outside wont do anything.
if RayCast and RayCast.Instance then
local bulletHoleFolder = workspace:FindFirstChild("BulletHoleFolder") or Instance.new("Folder",workspace)
bulletHoleFolder.Name = "BulletHoleFolder"
local bulletHole = game.ReplicatedStorage.GibBulletHole:Clone()
bulletHole.Parent = bulletHoleFolder
bulletHole.CFrame = CFrame.lookAt(RayCast.Position, RayCast.Position + RayCast.Normal);
game.Debris:AddItem(bulletHole, 63)
end
If this doesn’t work I have a script that I made a few months ago that you could experiment with:
RunService.Stepped:Connect(function()
local raycaster = script.Parent
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {raycaster, dotFolder:GetChildren()}
local range = 100
local origin = raycaster.Position
local dir = raycaster.CFrame.LookVector.Unit * range
local result = workspace:Raycast(origin, dir, params)
if result ~= nil then
dot.CFrame = CFrame.lookAt(result.Position, result.Position + result.Normal);
end
end)