How to make a prop roll in a certain direction

I’m trying to make a simple entity that rolls to people and kills them, and, well, i’m having trouble making it roll into the right direction.

Here it’s the relevant code:


		timer.Create("sounds_roll"..self:EntIndex().."", 2, 0, function()
			self:EmitSound(table.Random(sounds), 75, 100)	
			for k, v in pairs(ents.FindInSphere(self:GetPos(),512)) do
				if v:IsPlayer() then
					self:GetPhysicsObject():AddAngleVelocity(self:GetPos() - v:GetPos())
				end
			end
		end)

I don’t know that to put on “self:GetPhysicsObject():AddAngleVelocity(here)” to make it roll into its target without taking into account its own angles. Every time it tries to roll, its own angles alter the direction it rolls so it doesnt roll in a consistent manner. It always changes direction.

What kind of operation should I put there to make it ignore its angles, or atleast, counteract them?

Here is the full code, for reference


AddCSLuaFile()



DEFINE_BASECLASS( "base_anim" )

ENT.PrintName		= "Combine Duplicator"
ENT.Author			= "Eddlm"
ENT.Information		= "Hunts for living things and kills them"
ENT.Category		= "The Hunt"

ENT.Editable		= true
ENT.Spawnable		= true
ENT.AdminOnly		= false
ENT.RenderGroup		= RENDERGROUP_TRANSLUCENT



function ENT:Initialize()
	if SERVER then	
		sounds ={"npc/scanner/scanner_scan1.wav","npc/scanner/scanner_scan2.wav","npc/scanner/scanner_scan3.wav","npc/scanner/scanner_scan4.wav"}
		
		self:SetName("Combine bouncer ball")
		self:SetModel( "models/XQM/Rails/trackball_1.mdl" )
		self:SetMaterial( "models/combine_citadel/combine_citadel001" )
		self:SetSolid(SOLID_VPHYSICS)
		self:SetMoveType(MOVETYPE_VPHYSICS)
		self:SetUseType(SIMPLE_USE)
		self:PhysicsInit( SOLID_VPHYSICS )		
		local phys = self:GetPhysicsObject()
		if (phys:IsValid()) then
			phys:SetMass(200)
			phys:SetMaterial("rubber")
			phys:SetBuoyancyRatio(0.9)
			phys:EnableGravity(false)
			phys:Wake()
			phys:SetAngleDragCoefficient(200)
		end
		
		timer.Create("sounds_roll"..self:EntIndex().."", 2, 0, function()
			self:EmitSound(table.Random(sounds), 75, 100)	
			for k, v in pairs(ents.FindInSphere(self:GetPos(),512)) do
				if v:IsPlayer() then
					self:GetPhysicsObject():AddAngleVelocity(self:GetPos() - v:GetPos())
				end
			end
		end)
	end
end

function ENT:OnTakeDamage( dmginfo )

	-- React physically when shot/getting blown
	self:TakePhysicsDamage( dmginfo )
	self:GetPhysicsObject():SetVelocity((dmginfo:GetInflictor():GetPos() - self:GetPos()) * 3  )
end

function ENT:Think()
end

function ENT:PhysicsCollide( data, physobj )
	if data.HitEntity:IsPlayer() or data.HitEntity:IsNPC()  then
		ent = ents.Create( "env_explosion" )
		ent:SetPos(self:GetPos())
		ent:Spawn()
		ent:SetKeyValue( "iMagnitude", "150" )
		ent:Fire("Explode",0,0)
		ent:Remove()
		timer.Destroy("sounds_roll"..self:EntIndex().."")
		self:Remove()
	end
end

function ENT:Use( activator, caller )	
	if ( activator:IsPlayer() ) then
	
		-- Give the collecting player some free health
		local health = activator:Health()
		activator:SetHealth( health + 5 )		
	end

end


function ENT:Draw()
	self:DrawModel()
end

Note: Its gravity is disabled for debug reasons, so I can see in wich direction it tries to roll.

You need to use Angle:RotateAroundAxis in order to adjust the angle of rotation regardless of orientation