Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make this bow shoot more accurate?

Argument variable is mouse

local Arrow=Instance.new'Part'
Arrow.Size=Vector3.new(.1,.1,1)
Arrow.CanCollide=false
Arrow.BrickColor=BrickColor.new'Brown'
Arrow.CFrame=Player.Character.HumanoidRootPart.CFrame+Argument.Origin.lookVector
local BodyForce=Instance.new'BodyVelocity'
BodyForce.Velocity=Argument.Origin.lookVector*50 -- this is probably what needs to be changed
BodyForce.Parent=Arrow
Arrow.Parent=workspace

I think the problem is that the arrow is heading to the mouse position that is very far away. What I mean is that it ignores the parts that are closer to the mouse... Let me just give you an example:

---- = arrow trail

[] = part

o = Position the arrow is heading

How it is currently:

----------------[]-------------o

How I want it to be:

--------------o[]

In-game:

https://gyazo.com/a1ec1fe268fe72e0322f0e697e2c2bc2

I would appreciate any help, thanks.

2 comments

0

the simple fix would be playing the game from 1st person

0

or you could use raycasting to point the arrow towords the first object the ray hit that would fix it i think

1 answer

@Nogalo

This works better but is this the right way of using raycasting? I'm new to it...

local ray=Ray.new(Player.Character.RightLowerArm.CFrame.p,(Argument.Hit.p-Player.Character.RightLowerArm.CFrame.p).unit*500) 
local ignore=Player.Character
local hit,position,normal=workspace:FindPartOnRay(ray,ignore)

local Arrow=Instance.new'Part'
Arrow.Size=Vector3.new(.1,.1,1)
Arrow.CanCollide=false
Arrow.BrickColor=BrickColor.new'Brown'				Arrow.CFrame=Player.Character.HumanoidRootPart.CFrame+Argument.Origin.lookVector
local BodyForce=Instance.new'BodyVelocity'
BodyForce.Velocity=(position-Arrow.Position)*2
BodyForce.Parent=Arrow
Arrow.Parent=workspace

1 comment

0

I don't like how the arrow speed depends on the length of the distance

This discussion is preserved as it was. New answers, comments, and votes are closed.