Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Questions about simulated projectile?

Asked by
Supint 60
8 years ago
local part = Instance.new("Part", workspace); part.Position = Vector3.new(0,50,0); part.Anchored = true; part.Size = Vector3.new(10,10,10); part.Name = "Projectile"; part.Position = workspace.First.Position
local t = 0
local x = 0
local y = 50
local z = 0
local muzzle_velocity = 630*3
local bullet_drop = 15*3
local head = workspace.First
local part_cf = part.CFrame

local abs = math.abs

while true do
    t = t + wait()*3
    --[[this line]]part.CFrame = part_cf * CFrame.new((muzzle_velocity*3)*t + 10,(part.Position - workspace.BasePlate.Position).Y - (45*(t*2)),0)
    last = part.Position
    if (head.Position - part.Position).magnitude > 2000 then break end
end

*I realize my equations are off, I modified them to my liking.

So I'm having trouble with the x-axis part of my equation. The y-axis part works fine. By that, I mean that where ever I move my part, it takes off from that point and modifies the Y axis fine. But my part is always teleported, along the X axis, as if it started at Vec(0,y,z). I want it to be as if it just starts from wherever it's actually at, in the X axis, instead of teleporting weidly.

Can someone help me figure out what I did wrong?

Answer this question