Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make this bow shoot more accurate?

Asked by
aiuis 85
7 years ago
Edited 7 years ago

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.

0
the simple fix would be playing the game from 1st person Nogalo 148 — 7y
0
or you could use raycasting to point the arrow towords the first object the ray hit that would fix it i think Nogalo 148 — 7y

1 answer

Log in to vote
0
Answered by
aiuis 85
7 years ago
Edited 7 years ago

@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
0
I don't like how the arrow speed depends on the length of the distance aiuis 85 — 7y
Ad

Answer this question