-
What do you want to achieve? Keep it simple and clear!
I wanna create moving tracers that start from the barrel of the gun. -
What is the issue? Include screenshots / videos if possible!
For some reason the barrel position is off. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I really have no idea how to fix this, because sometimes it just fixes itself and starts creating tracers from the barrel
Here is how it looks when its off
And here is how it should look like
Function that creates the tracers
function m.createTracer(origin: Vector3, target: Vector3, hitPart: BasePart, normal: Vector3)
local bulletSpeed = 750
local direction = (target - origin).Unit
local distance = (target - origin).Magnitude
local travelTime = distance / bulletSpeed
local tracer = assets.Tracer:Clone()
tracer.Position = origin
tracer.Parent = workspace
local goalPosition = origin + direction * distance
local tweenInfo = TweenInfo.new(travelTime, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0.015)
local tween = tweenService:Create(tracer, tweenInfo, {Position = goalPosition})
tween:Play()
task.delay(travelTime, function()
tracer.Trail.Enabled = false
task.wait(1)
tracer:Destroy()
end)
end
i just pass the .Position property of the Barrel part for the origin.