Quick help with a Cryptic LUA function...

I’m trying to make an entity track myself (like the camera does) using the ent:SetTracking() function. However, this function is not on the wiki, and the only reference I have is its use in some addons I downloaded. I’m not sure how to make it work, and I would really like to know how to use it. Any help is appreciated. Thanks!

[lua]
function ENT:SetTracking( Ent, LPos )

if ( Ent:IsValid() ) then

    self:SetMoveType( MOVETYPE_NONE )
    self:SetSolid( SOLID_BBOX )

else

    self:SetMoveType( MOVETYPE_VPHYSICS )
    self:SetSolid( SOLID_VPHYSICS )

end

self:NextThink( CurTime() )

self:SetvecTrack( LPos );
self:SetentTrack( Ent );

end
[/lua]

I found this in the camera stool but it is the only trace to that function I can find so if that isn’t what you are looking for double check it is not in the addon.

[lua]
local targetvector = ply:GetPos()
local ang = (targetvector - self:GetPos()):Angle()
self:SetAngles(ang)
[/lua]

Run that each time you want to update the angle to face ply.

I thought of that, but wouldn’t resetting the angles using SetAngles every frame be expensive and cause lag?

ent:SetAngles() is what sets the angle. It is the only thing you can do to set the angle.

If you want it to happen every think, you must tell it to every think.

This is the bare bones of how to accomplish this task, and the same thing the camera does.

This is also not heavy in the slightest.

What Bletotum said, tho you can also just make the client render the angle using something like:
[lua]
function ENT:Draw()
ENT:SetRenderOrigin(pos)
ENT:SetRenderAngles(ang)
self:DrawModel()
end
[/lua]
Just remember that this have to be client-side and it won’t actually change the physical angle of the entity.
If the script is server-side or you need it to interact with it: I suggest you’re doing the script Bletotum gave you.

You can also use StartMotionController and PhysicsSimulate and calculate the angular impulse works really well with prediction and all