Currently trying to make a boss fight in which the boss tracks onto the player and rotates to follow/watch them. I’m currently just using CFrame to do this as I maintain the current position of the boss but change the rotation to the players. This obviously works for X and Z but for Y the boss just falls over. I’m looking for a more efficient way of doing this. One that involves the upper body rotating up to look at the player while the body stays grounded.
Here’s my code so far:
repeat task.wait()
if tween == nil and player then
local modelPos = enemy.PrimaryPart.Position
local playerPos = player.Character.PrimaryPart.Position
local lookVector = (playerPos - modelPos).unit
local lookRotation = CFrame.new(modelPos, modelPos + lookVector)
local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
tween = game:GetService("TweenService"):Create(enemy.PrimaryPart, tweenInfo, {CFrame = lookRotation})
tween:Play()
tween.Completed:Wait()
end
enemy:SetPrimaryPartCFrame(CFrame.new(enemy.HumanoidRootPart.Position, enemy.PrimaryPart.Position + (player.Character.HumanoidRootPart.Position - enemy.PrimaryPart.Position).Unit))
until not attackAny.IsPlaying or not player