So I am currently working on a system that involves NPCs for my game, the problem is that what I need to do is make the NPCs face the player, whilst moving to a certain location.
Now the movement and looking works fine, except when I use the function to make it look at the Player, the NPC begins to stutter, but still move forwards towards the given location.
After removing the Look at function I can confirm it was the problem, and I believe its cause its disrupting it some how and just making the NPC not walk as smoothly, so my question is simple, how can I fix this?
some code snippets
look at function
local module = {}
function module:EnemyFacePo(Model:Model, Position:Vector3)
local CurrentPosition = Model.PrimaryPart.Position
local LookAt = Vector3.new(Position.X, CurrentPosition.Y, Position.Z)
Model.PrimaryPart.CFrame = CFrame.new(CurrentPosition, LookAt)
return
end
return module
Enemy code for moving
EnemyFunctions:EnemyFacePo(Model, TargetRoot.Position)
Humanoid:MoveTo(TargetRoot.Position + OffsetPo)
Thanks!