Formula question. Getting an entity to point at vector

This is probably a really wanted formula. So here I am asking for it.

I have an entity. I want it to face towards a players eyetrace.hitpos…

What is the formula for this? Thanks.

You could use:

PlayerSelectSpawn requires a point-entity to be returned, you could use the point-entity to accomplish this, set position of the point entity then call face towards.

Or, you could do some math: http://forum.facepunch.com/showthread.php?t=1367363&p=43994751&viewfull=1#post43994751

There’s also this for Nextbots( ? ): http://wiki.garrysmod.com/page/CLuaLocomotion/FaceTowards

[lua]
local mt = FindMetaTable(“Entity”)
function mt:PointAtVec(vec)
local dir = vec - self:GetPos()
self:SetAngles(dir:Angle())
end
[/lua]
Untested. Use as ent:PointAtVec(pos)

EDIT: Now tested. Works.

Thanks this worked for my uses.