How exactly does SetEyeTarget work?

Definitely having problems here. According to the wiki it is simply to set an absolute world vector and the ragdoll will look in that direction. But when I create a Soldier and Heavy opposite each other, then:

ent_Heavy:SetEyeTarget( ent_Soldier:GetPos() )

the Heavy seems to look to the bottom left corner. If I try a relative position using:

ent_Heavy:SetEyeTarget( ent_Heavy:WorldToLocal( ent_Soldier:GetPos() ) )

the Heavy seems to look to the far left. Even if I use the “old style” of heavy:pos - soldier:pos and the other way around. How do I go about having the Heavy look directly at the Soldier? And for that matter, cross eyed?

ent_Heavy:SetEyeAngles( (ent_Soldier:GetPos() - ent_Heavy:GetPos()):GetNormalized():Angle() )

oops sorry that’s for players

e: SetEyeTarget just moves their eyes, not their head or body. If that’s what you want and that’s what you’re trying to say, then
ent_Heavy:SetEyeAngles( ent_Soldier:EyePos() )

[ERROR] attempt to call method 'SetEyeAngles' (a nil value)

And yes, I just want to move the eyes.

Sorry I meant
ent_Heavy:SetEyeTarget( ent_Soldier:EyePos() )

it could be that the soldier ent has a weird origin position. You should test that it works with something smaller and simpler, like a soda can

Then use the soldier’s EyePos() to get his face

Ok. Spawned a Heavy, spawned a Soda, and manually typed things in:

> GetDetails()...
Entity [10][prop_ragdoll]

> GetDetails()...
Entity [206][prop_physics]

> Entity(10):SetEyeTarget(Entity(206):GetPos())...

The result:

What am I missing?

I think you might have to do what the eye poser does here, it gets the position relative to the eyes attachment.

[editline]10th September 2016[/editline]

So maybe:

local lookat = Vector( 0, 0, 0 )

local attachment = ent:GetAttachment( ent:LookupAttachment( "eyes" ) )
local LocalPos, LocalAng = WorldToLocal( lookat, Angle( 0, 0, 0 ), attachment.Pos, attachment.Ang )
ent:SetEyeTarget( LocalPos )

Ah, so it is relative, but not a simple kind of relative.

Thank you very much! Wish the wiki had this example at hand.