robloxapp-20231121-1405214.wmv (817,9 КБ)
The problem is that the NPC does not smoothly keep eye contact with the enemy. Therefore, how to act?
for i = 0, 30 do
local direction = (EnemyTorso.Position - parent.PrimaryPart.Position).unit
parent:SetPrimaryPartCFrame(CFrame.new(parent.PrimaryPart.Position, EnemyTorso.Position + direction))
parent.Humanoid.WalkSpeed = 18
parent.Humanoid:MoveTo(retreatPositionNPC)
wait()
end
1 Like
Try disabling auto-rotate in the humanoid when it is retreating
1 Like
Thanks! I am very grateful!!!
Although it is possible to make sure that he constantly maintains eye contact. So that when he retreated, he looked at his enemy. Yes, that’s how to do it?
Assuming that you want it to be constantly looking at the player, you should use a while loop (don’t forget wait() to prevent it from overloading), that constantly makes it look at the player.
You should also look at :LookAt to achieve the looking functionality
Using the CFrame change is a buggy thing. You’ve already seen it on the video. Can you suggest something else, like bodyVelocity and the like?