I am trying to create a bow and arrow atm and originally I had used BodyVelocity to launch the arrow, but I realized that there is no way to create arrow drop with BodyVelocity (I think, If I’m wrong please let me know). So I am trying to switch to BodyForce at the minute
My issue right now is that I can’t figure out how to send the projectile to the mouse position.
Here is the code I have right now
local bf = Instance.new("BodyForce")
bf.Force = Vector3.new(direction - script.Parent.Parent.HumanoidRootPart.Position).Unit * arrow:GetMass() * 10
bf.Parent = arrow
(direction is just mousePos)
I would not use any body movers, and instead calculate the initial velocity you need to reach your goal and just set it directly, like the basketball in this article:
This file has been truncated.
> This guide was originally written for [scriptinghelpers](https://scriptinghelpers.org/). The original can be found [here](https://scriptinghelpers.org/blog/modeling-a-projectiles-motion).
As a somewhat active member of the Scripting Helpers discord one of the most common questions I see is how to have a projectile travel an arc. Most people want to know how to do this for things like basketballs or cannon balls and so forth. Since this is such a popular question I thought it would be worth writing a blog post on it and talking about a few other things we can extend from our findings.
## Table of Contents
* [Deriving the equation](#deriving-the-equation)
* [Basketball example](#basketball-example)
* [Jump power and height](#jump-power-and-height)
* [Mapping the projectiles path with a beam](#mapping-the-projectiles-path-with-a-beam)
## Deriving the equation
Using basic knowledge of physics and simple calculus we can derive the basic equation of motion that a projectile will take.
We know that the derivative of position with respect to time is velocity and that the derivative of velocity with respect to time is acceleration. Thus, the reverse is also true, the integral of acceleration with respect to time is velocity and the integral of velocity with respect to time is position.
In our case we know that the only acceleration affecting our objects is gravity. Therefore, all we must do is integrate gravity with respect to time twice to give us an equation for position.
I appreciate the source and I actually plan on looking to use that instead of body velocity, but I’m having an issue I can’t fix with this script.
I’ve had this issue before where the farther from the character you click, the faster the projectile travels. Last time I just added .Unit to the end of the velocity formula but now that is not working and actually messing up the formula, and idea on how to fix this?
local v0 = (mouse.Hit.p - x0 - 0.5*g*t*t)/t
My bad, I thought that’s the effect you were looking for.
Do you just want the arrow to just have an initial velocity in the direction of your mouse? Because that’s just
arrow.Velocity = (mouse.Hit.Position - v0).Unit * initialSpeed
Ah this worked for me after i changed the “t” variable to a smaller value, appreciate the help