Projectile Motion

I’m not quite sure what I am doing wrong.

wikipedia
image
x

local function x(t)
	return v.X * t * math.cos(a)
end

y

local function y(t)
	return v.Y * t * math.sin(a) - 1 / 2 * g * math.pow(t, 2)
end

Projection


code

local v = Vector2.new(16, 50)
local a = 45
local g = workspace.Gravity

local function x(t)
	return v.X * t * math.cos(a)
end

local function y(t)
	return v.Y * t * math.sin(a) - 1 / 2 * g * math.pow(t, 2)
end

for t = 0, 1, 1 / 144 do
	local Part = Instance.new("Part")
	Part.Color = Color3.fromRGB(255, 0, 0)
	Part.Material = Enum.Material.Neon
	Part.Transparency = .5
	Part.Name = ("%d"):format(t)
	Part.Parent = workspace
	Part.Size = Vector3.new(1, 1, 1)
	Part.Position = Vector3.new(x(t), y(t), 0)
	Part.CanCollide = false
	Part.Anchored = true
end

local Part = Instance.new("Part")
Part.Color = Color3.fromRGB(0, 255, 0)
Part.Material = Enum.Material.Neon
Part.Transparency = .5
Part.Parent = workspace
Part.Size = Vector3.new(2, 2, 2)
Part.Position = Vector3.new(0, 0, 0)
Part.CanCollide = false

Part.AssemblyLinearVelocity = Vector3.new(v.X, v.Y, 0)

for t = 0, 1, 1 / 144 do
	local Clone = Part:Clone()
	Clone.Color = Color3.fromRGB(0, 0, 255)
	Clone.Parent = workspace
	Clone.Size = Vector3.new(1, 1, 1)
	Clone.Anchored = true
	task.wait(1 / 144)
end

I’m not sure why the projected path is different from the actual path, I am trying to project the path that would be formed when a player jumps, v.x is walkspeed v.y is jumppower. I’d like to know why it is different and how I can fix this.

2 Likes