Hello, I am making a script that simply lets your character throw a C4 and let it stick to most objects. Though I’m trying to force the bomb to be launched at a trajectory so the bomb will always be facing forward no matter what it is on.
The code for it to be thrown:
local forceMultiplier = 50
C4:ApplyImpulse(Direction * forceMultiplier)
local touchedPart = false
while Run.Heartbeat:Wait() do
for _, v in pairs(C4:GetTouchingParts()) do
if not v:IsDescendantOf(Char) and not v:IsDescendantOf(C4) and not touchedPart then
print("Touched", v)
touchedPart = true
C4.Parent = v
local weld = Instance.new("WeldConstraint")
weld.Part0 = v
weld.Part1 = C4
weld.Name = "C4Sticking"
weld.Parent = C4
C4:SetAttribute("Activated", true)
C4.CanCollide = false
end
end
end
I’m thinking about either changing the C1 or trying to change the trajectory itself but I’m not too good at both physics and math.
While the bomb is in the air: while not C4:GetAttribute("Activated")do C4.CFrame = CFrame.lookAt(C4.Position, C4.Position + C4.AssemblyLinearVelocity.Unit, C4.CFrame.UpVector) end