I want to make an NPC confront a player from behind, left, right, or front. However, I know how to make the NPC confront the player from the front, but not from other angles. How can I possibly achieve this goal?
1 Like
Here’s the target goals you could use:
local back = -root.CFrame.lookVector.Unit*5
local front = root.CFrame.lookVector.Unit*5
local right = root.CFrame*CFrame.new(-5, 0, 0)
local left = root.CFrame*CFrame.new(5, 0, 0)
root being the HumanoidRootPart of the NPC.
I might’ve mixed up left with right, but you could use these as the target positions for moving the NPC to them, but you’d also want to update these per-frame so the position is always accurate.
3 Likes
What @C_Sharper said,
make the npc moveto these positions which are closer to them by getting the position of these cframes, then calculating the magnitude
you can also make npc face the player by changing its cframe but keepinmg the position and every orientation value except for y, and use cframe.new(pos,look) and then get the orientation of that, use math.rad for the y, then boom
1 Like