Bow and arrow problems

Recently I’ve been interested in making some realistic bows! After a few minutes I realized that the only way I could think of shooting arrows didn’t look the best.

I want the arrows to go in an arch instead of facing the same direction throughout its flight. How would I go about doing this??

Here’s my current code:

local arrow = Instance.new("Part")
arrow.Size = Vector3.new(0.5, 0.5, 2)
arrow.Name = "Arrow"
arrow.CanCollide = false
arrow.BrickColor = BrickColor.new("Really red")
arrow.Parent = workspace
arrow.CFrame = script.Parent.CFrame

local velocity = Instance.new("BodyVelocity")
velocity.MaxForce = Vector3.new(100000, 100000, 100000)
velocity.Velocity = arrow.CFrame.LookVector * Vector3.new(50, 50, 50)
velocity.Parent = arrow

wait(0.1)

velocity:Destroy()

arrow.Touched:Connect(function(hit)
	if hit ~= script.Parent then
		local weld = Instance.new("WeldConstraint")
		weld.Part0 = arrow
		weld.Part1 = hit
		weld.Parent = arrow
	end
end)

maybe use raycast or fastcast(30…)

When I made my bows way back when, I had to pretty much code the trajectory.
To do this you can definitely use recursion and raycasting.

Something like this

local function moveArrow(arrow, speed)
   local angle = arrow.Orientation.Y > 10 and CFrame.Angles(0, math.rad(5), 0)
   arrow.CFrame = arrow.CFrame * CFrame.new(0,0,speed) * angle 
   local raycastHit -- code needs to be completed
       
   
   if raycastHit then
      arrow:Destroy()
      if raycastHit.Parent:FindFirstChild("Humanoid") then
          raycastHit.Parent:FindFirstChild("Humanoid").Health -= 30
      end
    else
      wait(.1)
      moveArrow(arrow, speed)
    end
end

Just an example above of something you could do

2 Likes

Ahh I see, Thanks I’ll give it a try! :smiley:

You can also change the cframe of the arrow each frame and face it toward its trajectory.

game:GetService("RunService").Heartbeat:Connect(function()
	arrow.CFrame = CFrame.lookAt(arrow.Position,arrow.Position + arrow.Velocity)
end)

5 Likes

Thanks this worked perfectly!!!

Make sure to disconnect the events after they landed to avoid memory leaks.

lcoal hb = game:GetService("RunService").Heartbeat:Connect(function()
	arrow.CFrame = CFrame.lookAt(arrow.Position,arrow.Position + arrow.Velocity)
end)
--call hb:Disconnect() when the arrow lands
3 Likes

BRO Ty you solved my biggest problem with arrow trajectory :blush:))