Making an NPC's Orientation Direction face a target position

How do you change an NPCs orientation so that it’s facing the direction of any position you have? Like for example what if you want the NPC to look at another player in the game? How would you do that?

Orientations don’t use normal CFrame(Origin, LookAt) methods, they’re based on Angles. So what would I do for this?

2 Likes

You could still utilised CFrame(Origin, LookAt) in order to achieve the same effect of an npc facing an object in question.

Although if you don’t want the npc to just rotate their torso upward then you gotta eliminate the Y Axis of the target by making it the character’s Y axis itself.

-- Simple facing system thingy
local HumaoidRootPart = script.Parent.HumanoidRootPart

while wait() do
	
	local Target = workspace.Target.Position
	
	HumaoidRootPart.CFrame = CFrame.new(
		HumaoidRootPart.Position, 
		Vector3.new(Target.X, HumaoidRootPart.Position.Y, Target.Z)
	)
end

6 Likes

I’m aware of this, and used it before. I just want to be more familiar with using Orientation, I haven’t practiced with Angles on Roblox when it comes to making parts face certain directions.

1 Like

Ah, I see, I might not be able to help you with this one then my apologies, but I felt like CFrame tends to be used more commonly throughout the game development though compared to Orientation

1 Like