Getting position based on a part and not world postions

I have a camera pan that pans to an offset position of an NPC and it works for NPC’s in some cases but not all.

local Goal = {CFrame = npc.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(210), 0) + Vector3.new(5, 2, 10)}

Problem is with the Vector3 line. The X and Z values need to depend on the NPC’s HRP and not the world space, as 5 in the X direction and 10 in the Z direction look perfect for these NPC’s


But other npcs with different orientations

Can see the NPC is not even in frame

You can simply change + Vector3.new(5, 2, 10) to * CFrame.new(5, 2, 10) so that you’re shearing and not just translating the CFrame; so all operations are essentially done within object space.

1 Like

Can’t do that. Vecto3 expected, got CFrame

local Goal = {CFrame = npc.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(210), 0) + CFrame.new(5, 2, 10)}

Sorry, edited my comment for clarity, you’d need to change the addition operator to the multiplication one (didn’t think to mention it!)