Hey, I’m working on a little raycast-projectile system and whilst I can do equations in class on projectiles I’m pretty limited with implementing them into luau. I’ve done this so far:

```
connections["renderStepped"] = run_service.PreRender:Connect(function(delta_time)
local projectile_origin = caster.Position
local projectile_direction = (final.Position - projectile_origin).Unit * 0.55 * cast_duration --* 0.28
local acceleration = Vector3.new(0, -workspace.Gravity / 2, 0) * 0.28
local projectile_displacement = Vector3.new(
(projectile_origin.X + projectile_direction.X + ((acceleration.X * (cast_duration^2)) / 2)),
(projectile_origin.Y + projectile_direction.Y + ((acceleration.Y * (cast_duration^2)) / 2)),
(projectile_origin.Z + projectile_direction.Z + ((acceleration.Z * (cast_duration^2)) / 2))
)
local ray_result = workspace:Raycast(projectile_origin, projectile_displacement - projectile_origin, params)
projectile_origin += projectile_displacement
if ray_result then
print("Hit")
projectile.CFrame = CFrame.new(ray_result.Position)
connections["renderStepped"]:Disconnect()
connections["renderStepped"] = nil
else
projectile.CFrame = CFrame.new(projectile_origin)
projectile.CFrame *= CFrame.Angles(0, math.rad(math.pi / 2), 0)
cast_duration += delta_time
end
if cast_duration >= 55 then
print("Cast terminated")
connections["renderStepped"]:Disconnect()
connections["renderStepped"] = nil
end
end)
```

I used s = vt for projectile_distance & a SUVAT equation of motion, s = ut + 1/2at^2 for displacement adding on the current position to the equation to make s = s0 + ut + 1/2at^2.

My issue is that even though I’ve provided a path for it to go to on the x axis, it doesn’t go that way only moving on the Y axis. It also prematurely terminates itself and ends the cast as if it’s hit something but it hasn’t. It might be something small and silly but if anyone could give me a hand it would be greatly appreciated.