I've been trying to script a spell where the character enters a stance, and orients itself towards the nearest enemy until the stance ends. I've currently been trying two ways which both ended in lackluster results.
The first method I used is a repeat loop where I constantly update the character's lookAt CFrame until the stance ends:
--Currently use 0,0,0 as the position of the enemy. spawn(function() repeat Character.HumanoidRootPart.CFrame = CFrame.new(Character.HumanoidRootPart.Position, Vector3.new(0,0,0)) wait() until inAction.Value == false end)
This method does not achieve what I want because while the character moves, it will "shake" the character because it will consistently update the orientation of the character while moving also orient the character towards the direction we move to.
The second method I use is to create a BodyGyro inside the character.
--While in stance, orient the character towards the nearest enemy. local Gyro = Instance.new("BodyGyro") --Currently CFrame towards the origin. Gyro.CFrame = CFrame.new(0,0,0) Gyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge) Gyro.D = -10 Gyro.P = 1 Gyro.Parent = Character.HumanoidRootPart
This does not really achieve what I want even when I tweak the D and P values of the BodyGyro, which is too slow or fast to orient the character.
Is there any other way I can orient the character towards a point smoothly?