Help with applying force to an entity

I have some SWEPs made that are about throwing watermelons, but the code for applying force is very confusing. Does anybody know an easy to understand code that I can use and change if I need to. Here is my code for SWEP:throw_attack.


function SWEP:throw_attack (model_file)
	
	local tr = self.Owner:GetEyeTrace()
 
	self:EmitSound(ShootSound)
	self.BaseClass.ShootEffects(self)
 
	if (!SERVER) then return end
 
	local ent = ents.Create("prop_physics")
	ent:SetModel(model_file)
 
	ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
	ent:SetAngles(self.Owner:EyeAngles())
	ent:Spawn()
 
	local phys = ent:GetPhysicsObject()
 
	if !(phys && IsValid(phys)) then ent:Remove() return end

	//this is what I need help with
	phys:SetVelocity(self.Owner:GetForward() * 500000 + Vector(5000,0,0))
 
	cleanup.Add(self.Owner, "props", ent)
 
	undo.Create ("Thrown_SWEP_Entity")
		undo.AddEntity (ent)
		undo.SetPlayer (self.Owner)
	undo.Finish()
end

The original code I had for force was:


phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() *  math.pow(tr.HitPos:Length(), 3))

Both codes are confusing and don’t work the way I want them to no matter how much I try to adjust them.

Before you understand what those functions do, you should really learn the physics behind it so you know what exactly it’s doing.

I still don’t understand how to make an effective code for adding force to a thrown entity. I’m trying to make a weapon that can shoot watermelons very far at high speeds without falling too much due to gravity.