So I am trying to make an Arrow that will rotate the Y Axis according to the Pos
argument. I Chose Y Axis because it seems to be rotating the arrow the correct way. If that’s confusing too you I’m trying to make an arrow similar to the pizza job in bloxburg. An Arrow that smoothly rotates according to a position.
I can’t seem to point the arrow correctly I used several methods and either push the arrow too far or not show the arrow at all
I’ve tried some solutions like Lerping but it goes way off into the map
Lerping Method
function CreateWaypoint(Destroy, Pos)
if Destroy then
local existingArrow = char:FindFirstChild("Arrow")
if existingArrow then
existingArrow:Destroy()
end
end
local Arrow = Objects.Arrow:Clone()
Arrow.Parent = char
Arrow.Anchored = false
local Motor6d = Instance.new("Motor6D", Arrow)
Motor6d.Part0 = char.Head
Motor6d.Part1 = Arrow
Motor6d.C0 = CFrame.new(0, 0, 0) -- Initial position relative to the character's head
Motor6d.C1 = CFrame.new(-0.0260685384, 0.0260690004, -1.74875546, -0.707106173, -8.40013854e-07, 0.707107842, 0.707107961, 5.41995234e-07, 0.707106352, -9.77227273e-07, 1, 2.10732296e-07) -- Initial orientation
local targetCFrame = CFrame.new(Pos.p, char.Head.Position) -- Calculate the target CFrame using the position 'Pos' and the arrow's current position
-- Function to interpolate (lerp) between two CFrames smoothly
local function lerpCFrame(cf1, cf2, alpha)
return cf1:Lerp(cf2, alpha)
end
local alpha = 0.05 -- Smoothing factor
while task.wait() do
Motor6d.C1 = lerpCFrame(Motor6d.C1, targetCFrame, alpha)
end
end
Replicated.CreateWaypoint.OnClientEvent:Connect(CreateWaypoint)
Orginal Code I need help on
function CreateWaypoint(Destroy, Pos)
if Destroy then char:FindFirstChild("Arrow"):Destroy() end
local Arrow=Objects.Arrow:Clone()
Arrow.Parent=char
Arrow.Anchored=false
local Motor6d=Instance.new("Motor6D",Arrow)
Motor6d.Part0=char.Head
Motor6d.Part1=Arrow
Motor6d.C0=CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 ) ---- The large numbers is to keep the motor6d above the head
Motor6d.C1=CFrame.new(-0.0260685384, 0.0260690004, -1.74875546, -0.707106173, -8.40013854e-07, 0.707107842, 0.707107961, 5.41995234e-07, 0.707106352, -9.77227273e-07, 1, 2.10732296e-07)
while task.wait() do
local TargetRoationPos ---- This were the Y Axis value will be
Motor6d.C1=Motor6d.C1*CFrame.fromOrientation(0,0.1,0) ----- This will were the Y Axis orentation will be updated according to the positon
end
end
Replicated.CreateWaypoint.OnClientEvent:Connect(CreateWaypoint)