-
What do you want to achieve?
while the npc is moving away I still want it to keep looking at the player
-
What is the issue?
I have this issue because I want the npc to look at the player while moving away. The problem is that when I set the cframe/orientation to still look at the player, it does not work and makes the moving npc clunky. My main issue is making the npc look at the player while moving away without interfering with its movement. -
What solutions have you tried so far?
cframes (cframe look at with primarypart) and setting the orientation and lerping the orientation and cframes.
Would coding the NPCs head’s CFrame LookVector as well as moving the NPC work?
You could use what you already have to move the NPC, but then also add code for the head itself. It might look weird as the head would be always facing the player no matter what angle the NPC is, but yeah.
Can’t use studio to test right now, but I’m sure that it would look weird. The head could be doing a 180 from where to body is, unless you code that to not be a thing. Like the head would face the player even if the NPC has it’s back turned.
no like im trying to make the whole npc face the player, like turning its primarypart (humanoidrootpart) to the player, problem is, its affecting the npc movement making it all clunky
use align orientation or the old bodygyro and set the cframe every time to
CFrame.new(npc.HumanoidRootPart.Position, lookPart.Position)
nevermind, cframe:inverse() did the trick, thanks
function OrientCharacter(HumanoidRootPart:BasePart,Target:Vector3)
local AlignOrientation = HumanoidRootPart:FindFirstChild("CharacterOrientation") or Instance.new("AlignOrientation",HumanoidRootPart)
local Attachment = HumanoidRootPart:FindFirstChild("COAttachement") or Instance.new("Attachment",HumanoidRootPart)
AlignOrientation.Name = "CharacterOrientation"
AlignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
AlignOrientation.RigidityEnabled = true
AlignOrientation.Attachment0 = Attachment
Attachment.Name = "COAttachement"
Attachment.CFrame = CFrame.new(HumanoidRootPart.Position,Vector3.new(Target.X,HumanoidRootPart.Position.Y,Target.Z)):Inverse()
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.