2D sprite that always faces the player?

Im building a horror game that is sort of voxel based, and i wanted to make the enemies and NPCs in a 3D environment game always face the player like in old FPS games like duke nukem 3D and DOOM, but only along the Y axis so they dont do that strange visual artifact if you are on a higher plane then they are. Im not sure how to do this, any help would be wonderful.

It is not clear how you want his billboarding to work. The visible side of a sprite is the back, so I’m going to assume you want the back of the sprite to face the camera. And that you only want to rotate around the ‘y’ axis. One way to enforce only rotating around the ‘y’ axis is to remove any ‘y’ component from the calculated vector. The code will be something like:

var v = transform.position - Camera.main.transform.position;
v.y = 0.0;
transform.rotation = Quaternion.LookRotation(v);