I’m trying to fire an object from a specific coordinate in a parabola shape so that it passes through another point as it’s vertex.
I’m using the formula v2 = 2gy + vi2
where vi would be equal to 0
g = gravity and y = Y displacement
Code:
local xEndPos = 280 local yEndPos = 120 local xStartPos = 60 local yStartPos = 260 local distance = yEndPos - yStartPos print ("distance " .. distance) local t = 1 / display.fps local a = t \* -9.8 local vy = math.sqrt(2 \* a \* distance) \* display.fps -- I don't understand why this is necessary vy = vy \* -1 -- vx isn't calculated yet either just trying to get y right for now proj:setLinearVelocity( vx,vy )
I should get about -278 as the initial velocity required to hit the End coords but I’m getting close to -396. Can’t work out what I’m doing wrong. Am I using the wrong formula or converting to frames incorrectly. Physics gravity is set to the default -9.8 m/s