Weird Projectile Behavior

So I was following a basic tutorial on how to make projectiles since I wanted to get into more complex math stuff. The entire tutorial was very clear and made it easy to understand but I was left puzzled when my script was behaving weirdly to what was happening on the tutorial. I don’t know if it was because the tutorial was already a bit over 2 years old, or it was just me doing something wrong without me noticing. From what I’ve noticed, it seems like the Vector3.new at the end of the force formula is causing something to happen, because It works normal before I add it, but I’m not sure since I even followed the tutorial completely to see if something was wrong. I am severely lacking sleep :fish:

Script located within ServerScriptService:

while true do
	task.wait(5)
	
	local startPos = workspace.Start.Position
	local endPos = workspace.End.Position
	
	local direction = endPos - startPos
	local duration = math.log(1.001 * direction.Magnitude * 1.001)
	local force = direction / duration * Vector3.new(0, game.Workspace.Gravity / 2, 0)
	
	local projectile = game.ServerStorage.Projectile:Clone()

	projectile.Parent = workspace ; projectile.Position = startPos
	projectile:ApplyImpulse(force * projectile.AssemblyMass)
	
	game.Debris:AddItem(projectile, 5)
end

This is the tutorial if you’re wondering:

3 Likes

Show your result. we dont understand what you have now by saying “Weird”

This line is supposed to be:

local duration = math.log(1.001 + direction.Magnitude * 1.001)

(You accidentally multiplied instead of adding)

Oh oops, thank you so much. I couldn’t really see the sign due to how zoomed out it was

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.