Help with accurate ApplyImpulse

I don’t know what to call this so I just called it this.
So I am trying to launch a projectile to a target but it misses.

local function PredictNextPosition(targetPosition, targetVelocity)
	local targetPos = targetPosition + targetVelocity
	local direction = targetPos - firePoint.WorldPosition <-- attachment
	local duration = math.log(1 + direction.Magnitude * 0.01)
	local force = direction / duration + Vector3.new(0, workspace.Gravity * duration * 0.5, 0)
	return force
end
local force = PredictNextPosition(targetPosition, targetVelocity)
projectile.PrimaryPart:ApplyImpulse(force * projectile.PrimaryPart.AssemblyMass)
-- its a model


I don’t know why it is missing.

What does this line do? I think this might be the issue.

I don’t know. I found it in this video:

Fixed.

local targetPos = targetPosition + targetVelocity
local direction = targetPos - firePoint.WorldPosition
local duration = 1
local force = direction / duration + Vector3.new(0, workspace.Gravity * duration * 0.5, 0)
return force

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