![]() ![]() Unsurprisingly, this gives us the max height time value doubled since it takes the same amount of time to go up as it does down. We can also look at the original position equation and solve for x(t) = 0 with the quadratic equation to find the time it takes for the jump land. We can rearrange this formula to find v0 (jump power) given a non-negative height. Noting that the initial height (position) is zero we’re left with the following formula to find jump height which we’ll define as h. We can take this time value and plug it into the position function to have a formula for jump height. We already know the derivative of the position function is v(t) so if we set it equal to zero and solve for t then we know the time value when the position function has reached its maximum height. Looking at an example position function we can see that since it’s a parabola, its maximum height coincides with a slope of zero. We know that the derivative of a function allows us to calculate the slope at any given point. To find the jump height we need again to draw on some basic calculus intuition. We can use this information with the position equation we derived to find the height of our jump or even the jump power we need to reach a certain height. Local rs = game:GetService("RunService").RenderStepped Ĭ.CFrame = CFrame.new(0.5*g*nt*nt + v0*nt + x0) įor those of you who are unaware the property Humanoid.JumpPower can be thought of as the v0 used to model a jump. Local v0 = ( - x0 - 0.5*g*t*t)/t Īlternatively we could do this directly with CFrames if we didn’t care as much about the collisions. Local x0 = hrp.CFrame * Vector3.new(0, 2, -2) Local bball = script.Parent:WaitForChild("Handle") Local hrp = :Wait():WaitForChild("HumanoidRootPart") To figure this out we define our target as x1 and rearrange the position function from above for v0. One of the neat things we can do with this equation is find the initial velocity needed to reach a certain target given time. Similar to before we’re left with some constant, C, and again we know that at t = 0 we should be at our initial position which we define as x0.Īwesome! We have a time-based equation for position! Basketball example ![]() Next, we’ll integrate velocity with respect to time to find position. We know that at t = 0 our velocity should be equal to our initial velocity which we will define as v0. Therefore, all we must do is integrate gravity with respect to time twice to give us an equation for position.ĭue to the rules of indefinite integration we are left with an unknown constant, C, but using some intuition we can figure this out easily enough. In our case we know that the only acceleration affecting our objects is gravity. 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. 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. Using basic knowledge of physics and simple calculus we can derive the basic equation of motion that a projectile will take. 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. ![]() Most people want to know how to do this for things like basketballs or cannon balls and so forth. The original can be found here.Īs 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. This guide was originally written for scriptinghelpers. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |