Entity Lua Problems

Hey guys, I’m trying to make an entity that when it spawns, it runs a timer that moves the entity back to the original position. The problem I’m having though is that the entity won’t move.

Here’s my init.lua for the entity.


AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )
print("Init")
function ENT:SpawnFunction( ply, tr )
	print("Init Spawn")
	if ( !tr.Hit ) then return end

	local SpawnPos = tr.HitPos + tr.HitNormal * 16
	local Ent = ents.Create( self.Classname )
	Ent:SetPos( SpawnPos )
	Ent:Spawn()
	Ent:Activate()
	timer.Create("VelocityKeep",1,0,function()
		Ent:GetPhysicsObject():ApplyForceCenter( (Ent:GetPos()-og_pos)*50 )
		if(math.random(1,50))then print("Force Call") end
	end)
	return Ent

end
local og_pos=Vector(0,0,0)
function ENT:Initialize() 
	print("Initialize")
	self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	
	local phys = self.Entity:GetPhysicsObject()
	if ( phys:IsValid() ) then
		phys:Wake()
	end
	og_pos=self:GetPos()
	self:SetDTFloat( 0, math.Rand( 0.5, 1.3 ) )
	self:SetDTFloat( 1, math.Rand( 0.3, 1.2 ) )
end

function ENT:SetupDataTables()
	print("SetupData")
	self:DTVar( "Float", 0, "RotationSeed1" )
	self:DTVar( "Float", 1, "RotationSeed2" )

end

function ENT:Think()
	print("Think")
end

function ENT:OnTakeDamage( dmginfo )
	self.Entity:TakePhysicsDamage( dmginfo )
end

Any help with this would be greatly appreciated! :slight_smile:

I am having the same problem. Please help this guy

Yeah, I’ve tried with SetVelocity as well and no difference. The ENT:Think() doesn’t seem to print() anything, and the only thing that actually does print is “Init”.

If you guys need anymore information do ask.