|
| 02 Jul 2016 05:33 PM |
im trying to make a arrow be shot towards the mouse's position, but its flying everywhere
script:
local tool = script.Parent local player = game:GetService("Players").LocalPlayer local mouse = player:GetMouse()
tool.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() local Arrow = Instance.new("Part", game.Workspace) Arrow.Size = Vector3.new(4, 1, 1) Arrow.Position = player.Character.Torso.Position + Vector3.new(0, 0, -5) Arrow.CanCollide = false local ArrowMesh = Instance.new("SpecialMesh", Arrow) ArrowMesh.MeshType = Enum.MeshType.FileMesh ArrowMesh.MeshId = "http://www.roblox.com/asset/?id=15887356" ArrowMesh.TextureId = "http://www.roblox.com/asset/?id=15886781" local Thrust = Instance.new("BodyThrust", Arrow) Thrust.force = Vector3.new(0, 0, 40000) Thrust.location = mouse.Hit.p end) end)
no errors btw |
|
|
| Report Abuse |
|
|
| |
|
| |
|
AxonMega
|
  |
| Joined: 29 Aug 2014 |
| Total Posts: 2403 |
|
|
| 03 Jul 2016 12:18 PM |
I don't think you understand what the location of a BodyThrust does. Look it up here: http://wiki.roblox.com/index.php?title=API:Class/BodyThrust
Also, try:
local force = Instance.new("BodyForce", Arrow) local direction = (mouse.Hit.p - Arrow.Position).unit*40 force.Force = direction + Vector3.new(0, Arrow:GetMass()*workspace.Gravity, 0) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:25 PM |
yea, i never really understood all of the bodymovers
ill give your script a shot
thanks |
|
|
| Report Abuse |
|
|
AxonMega
|
  |
| Joined: 29 Aug 2014 |
| Total Posts: 2403 |
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Jul 2016 12:51 PM |
If you just want it to travel to the cursor's position in the world, you could get away with using CFrame if you don't want to account for drop
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Jul 2016 12:54 PM |
Even then you could fake gravity by exponentially increasing the drop rate
9.8 meters per second squared
|
|
|
| Report Abuse |
|
|
Isostae
|
  |
| Joined: 14 Sep 2014 |
| Total Posts: 17706 |
|
|
| 03 Jul 2016 12:55 PM |
"Thrust.force = Vector3.new(0, 0, 40000)"
that would be the problem.
- Isosta |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:57 PM |
No, that wouldn't be the problem. That would be correct, if he was using a BodyGyro and not setting Location. In fact, that would probably be better than a BodyForce because then at least it would angle towards the target.
Sort of.
I mean, personally I would make it be oriented along its trajectory, because who has ever even heard of an arrow falling and still pointing upwards? |
|
|
| Report Abuse |
|
|