Hello! I’m making an NPC system and when the user talks to an NPC, it focuses the face of the NPC. When they open up the shop area, a pop-up shows on the right side where the user can sell items. I’d like to center the head of the NPC in the area where the pop-out is not. I’ve tried googling, but I can’t quite get a decent query so I figured I’d ask here.
this may be a kind of roundabout method of solving this(there is probably a better way), so bear with me
use camera:ScreenPointToRay(x,y) or camera:viewportPointToRay(x,y) which will return a ray object, for the x and y arguments put them at wherever you want the npc to be on screen
you can get a point a set distance away from the camera by doin this
local ray = camera:ViewportPointToRay(500,500,1)--500,500 is placeholder
local _3dPos = Ray.Origin + Ray.Unit * 10--10 is distance from camera
local offset = camera.CFrame.Position - _3dPos
camera.CFrame = _3dPos+offset
sorry if i explained this bad
here’s my implementation(it works) camerathing.rbxl (44.1 KB)