Making it stop a a metre behind you

I thought this was more of a request than a question. Basically what this script does is spawn an entity which follows you. Credits to WhiTAkeR for the original code. What I’d like for it to do is to stop 1 metre behind you when you stop. If anyone could do this for me that would be great.


function ENT:Initialize()
	self.Entity:SetModel ("models/madebycn/r5d2.mdl")
	self.Entity:PhysicsInit(SOLID_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
	self.Entity:SetSolid(SOLID_VPHYSICS)
	self.PhysObj=self.Entity:GetPhysicsObject()
		if(self.PhysObj:IsValid()) then
		self.PhysObj:EnableGravity(false)
		self.PhysObj:Wake()
		end
	
	end
	
ENT.OurHealth = 100

function ENT:Use( activator, caller )
	self.Target = activator
end

function ENT:SpawnFunction ( ply,tr )
	if not tr.HitWorld then
	return 
	end
	local ent = ents.Create("construct")
	ent:SetPos(tr.HitPos + Vector(0,0,50))
	ent:Spawn()
	ent.Target = ply
	return ent
end
function ENT:OnTakeDamage(dmg)
	self.Entity:TakePhysicsDamage(dmg)
	if dmg:GetAttacker():IsPlayer() then
		self.angry = true
	end
end

function ENT:Think()

	if ValidEntity(self.Target) and not self.Target:Alive() then 
	
		if self.angry then
			self.angry = false
			end
	end
	if self.angry then
		if ValidEntity (self.Target) then
		
					local eyes = self.Target:LookupBone("ValveBiped.Bip01_L_Toe0")
			   
					local pos = self:GetPos()
   
					local tpos = self.Target:GetBonePosition(eyes)

					local vec = (tpos - pos)
			   
					local ang = vec:Angle()
			  			   
					self:SetAngles(ang)
					   
					local vecnorm = vec:GetNormal()
			   
					local phys = self:GetPhysicsObject()
			   
					phys:AddAngleVelocity (phys:GetAngleVelocity()*-1)
			  
					if math.random(50) == 1 then
						phys:ApplyForceCenter(vec * 20 * phys:GetMass()) 
					end
					phys:SetVelocity(phys:GetVelocity() + Vector(0,0,2*math.cos(4*CurTime())))		
					
					if vec:Length() >= 250 then
					phys:ApplyForceCenter(vecnorm * 250 * phys:GetMass()) 
				elseif vec:Length() > 40 then
					phys:ApplyForceCenter( vec * phys:GetMass())					
				end
		end
			
			elseif ValidEntity(self.Target) then 
			
					local eyes = self.Target:LookupBone("ValveBiped.Bip01_L_Toe0")
			   
			   local pos = self:GetPos()
   
			   local tpos = self.Target:GetBonePosition(eyes)

               local vec = (tpos - pos)
			   
			   local ang = vec:Angle()
			  			   
			   self:SetAngles(ang)
					   
			   local vecnorm = vec:GetNormal()
			   
               local phys = self:GetPhysicsObject()
			   
			   phys:AddAngleVelocity (phys:GetAngleVelocity()*-1)
			   
				if vec:Length() >= 170 then
					phys:ApplyForceCenter(vecnorm * 170 * phys:GetMass()) 
				elseif vec:Length() > 40 then
					phys:ApplyForceCenter( vec * phys:GetMass())					
				end
										
				phys:SetVelocity(phys:GetVelocity() + Vector(0,0,2*math.cos(4*CurTime())))
		
	end
end


It’s all good giving credits to Whitaker for his code, but have you actually asked him if you can use it? I know him personally, I’m sure he will be Okay with it.