You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I am attempting to make a cannon that follows an arc using the quadratic equation
What is the issue? Include screenshots / videos if possible!
The current height prints out 240ish at t-0 instead of 0. I am wondering if I missed to convert the height unit in studs to feet but cant seem to figure out how to solve it.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
local ProjectileService = {}
local RunService = game:GetService("RunService")
function ProjectileService:FireProjectile(startingPos, Force)
local projectile = script.Projectile:Clone()
projectile.Position = startingPos
projectile.Parent = workspace
local connection
local t = tick()
local startingV = 150 * 1.4
local startingH = startingPos.Y
connection = RunService.Stepped:Connect(function()
local timeinSeconds = tick() - t
--currentHeight = quadratic coefficent * gravity(m/s^2) * TimeInSeconde^2 + (StartingVelocity m/s^2 * TimeInSeconds) + height
local currentHeight = (-.5) * (54.936) * (timeinSeconds^2) + (startingV * timeinSeconds) + 0
print(currentHeight)
--projectile.CFrame = CFrame.new(projectile.Position.X, currentHeight, projectile.Position.Z)
if currentHeight < 1 then
connection:Disconnect()
end
end)
end
return ProjectileService
it turns out @Ozzypig that using distributed game time was a better option. One more question would be how I can remove the choppyness of the part moving across the arc. I thought it would be smoooth as stepped fired every 1/60th of a second