Is there any way to increase the time taken, without increasing the height?
Bump.
Is there any way to increase the time taken, without increasing the height?
Been stumped on this for a while, your current inputs are the time it takes, and the target position. How would one switch it up to determine the velocity using the angle of velocity, and the target position. Im sure its probably very simple once you understand the maths behind it, but I donātā¦
Not sure if this works perfectly, but from my testing I think it worked.
What it does is that it creates a custom gravity, which is determined from the vertex of the parabola (zero of its derivative) which is at the point (timeHalf, h).
The gravity is basically the a
value of the parabola, so we can just get it from the vertex.
It then uses a VectorForce to have its own gravity.
timeTaken
is obviously the time to reach the point
h
is the maximum height that it reaches
local timeHalf = timeTaken/2
local g = Vector3.new(0,-2*h/timeHalf^2,0)
local v0 = (to - from - 0.5*g*timeTaken*timeTaken)/timeTaken;
-- give it custom gravity
local vf = Instance.new("VectorForce")
vf.ApplyAtCenterOfMass = true
local att = Instance.new("Attachment")
att.Parent = ball
vf.Attachment0 = att
vf.Force = Vector3.new(0, workspace.Gravity*ball.Mass,0) + g*ball.Mass
vf.Parent = ball
ball.AssemblyLinearVelocity = v0
One issue is that if you make the timeTaken too long, it will look like a feather falling downward.
Hope this helps.
Honestly I donāt think you need any calculus for this If you want a time based equation for position just find the difference between the projectile and target hereās an example. You could easily modify this to hit a target moving at a constant speed simply calculate the future position of it
local time = 5 -- Time to reach the target (seconds)
local g = workspace.Gravity
local deltaX = targetPos.X - projectile.Position.X
local deltaY = targetPos.Y - projectile.Position.Y
local deltaZ = targetPos.Z - projectile.Position.Z
local Vx = deltaX / time
local Vz = deltaZ / time
local Vy = (deltaY + 0.5 * g * time^2) / time
projectile.Velocity = Vector3.new(Vx, Vy, Vz)
hey ego moose what is the v0 variable is it the look vector
also is there to make this formula or change it or do something to make the projectile go move fast horizontally but also limit the -y velocity so it increase at a certain velocity
is it possible to lerp this cframe so its more smooth without making it look strange
V0 is velocity at time 0. If its the look vector then the part will move where it is looking.
Increase in velocity means acceleration, so change the gravity value and increase velocity.
Yes it is already done in the video in the post you replied.
oh okay thanks sorry if I did not understand
wait thereās one issue can I limit -y velocity like as the acceleration is increasing I can make it stop increasing at fall at a constant speed without increasing only when its reached a certain velocity on the -y axis
Hi, youāre trying to implement Terminal Velocity. The way it typically works is that you have an additional force (other than gravity) that represents drag or air resistance, which points up instead of down, and is proportional to your speed. When youāre stationary, this force is 0, and when you reach your terminal velocity, this force is equal to gravity and they cancel out. If you were to go faster than terminal velocity, this force would be greater than gravity and you would slow down until you reached terminal velocity again.
Hereās an interactive graph that shows how velocity evolves when you implement air resistance. g
represents the value of gravity, while m
represents air resistance (value between 0 and 1). Your terminal velocity would be v_t = g/m
as indicated by the green line on the graph (the red dots show the evolution of velocity, which falls toward the green line but never go past it). Finally, the blue curve follows the equation of position over time, when air resistance is taken into account. It starts off looking like a parabola (because thereās no air resistance at first), then eventually slows down to a straight line (because air resistance is equal and opposite to gravity, so the falling object no longer accelerates nor decelerates).
So if you just want your falling object to have a terminal velocity, add a script within them that regularly updates an āair resistanceā force which should be equal to -m * M * object.Velocity.Y
(m is the air resistance factor between 0 and 1, and M is the mass of the object). And if you want to try and get a trail modeling the objectās motion, try using the formula for the blue curve in that interactive graph.
thank you this was helpful I am going to learn more about this and try to understand how everything works