So, what I’m trying to make is a doom type system where any NPC that is in stunned phase the player can press E to perform a execution on the NPC so far I came to the player getting to the NPC itself but I need to make the player to look at the NPC itself before the animation plays
1 Like
Hi there!
I believe what you are looking for is Model:SetPrimaryPartCFrame, where the model is the player’s character and the primary part is the humanoid root part. This will move the entire character towards where you point the humanoid root part. For the CFrame, I believe CFrame.fromMatrix() would work (CFrame.new got deprecated for the LookAt parameter). Scroll down to that and it gives you a wonderful explain of how to use it.
Hope that helps!
2 Likes
function faceTarget(player, target, camZoom)
local root = player.Character.HumanoidRootPart
local camera = game.Workspace.Camera
root.CFrame = CFrame.new(root.Position, target.PrimaryPart.Position)
camera.CFrame = root.CFrame * root.CFrame.looVector * camZoom
end
I would recommend manipulating the CFrame of a of BodyGyro in a similar fashion to make parts face other parts, but this is the CFrame math to make something face a target. (it’ll reposition the camera accordingly)
1 Like