Welding bullet holes

I’m currently adding blood spots to my game.
I need to weld decals to a part, but I don’t want to use WeldConstraint, instead I prefer the regular Weld (I’m doing everything in a hard way).
I can calculate the position of C1 without issues, but when it comes to calculating lookvector I can’t figure out how to.

local ins = result.Instance
local pos = result.Position
local normal = result.Normal

local bloodClone = blood:Clone()
bloodClone.Parent = ins
local weld = Instance.new("Weld")
weld.Part0 = ins
weld.Part1 = bloodClone
weld.C1 = CFrame.new(ins.CFrame.Position - pos, (ins.CFrame.Position - pos) + lookcalc)
weld.Parent = bloodClone

debris:AddItem(bloodClone, 5)

Here is a part of my code, I need to put real calculations of lookvector instead of lookcalc.

5 Likes

Why do you not want to use WeldConstraint :sob:
This is literally what the instance was made for.

2 Likes

I want to learn how to calculate things, not just create an instance.

2 Likes

Oh sorry. Normally you would just subtract the vector from the other vector but I’m not too sure how you would approach this with cframes. You’re correct with the first part of the calculation but you’ve got to keep the angle the whole way through.

Give this a try

weld.C1 = ins.CFrame * CFrame.new(pos-ins.Position)

This just finds the offset from the centrepoint of the instance (ins.Position) and then adds it to the cframe of the actual instance. This allows rotation to also be put into account when.

If this doesn’t work try assigning it to weld.C0 instead
CFrame confuses me sometimes

CFrame.lookAt(result.Position, result.Position + result.Normal):ToObjectSpace(result.Instance.CFrame)

Found and answer to my question in older versions of my workspace game.
Had to scroll down through 200 versions of the place.

1 Like

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