#Override one part of an animation's CFrame?

1 messages · Page 1 of 1 (latest)

sinful bone
#

I have an NPC that is constantly doing an idle animation, but i'd like its eyes to track the player while it's doing so. I had previously done this, but the npc was not being animated, but rather just tweened. SO I tried replicating it to here, but it seems to move the entire body.

#
local eyes = workspace.JJ.Parts.Eyes

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local pHead = character:WaitForChild("Head")

local animator = Instance.new("Animator")
animator.Parent = workspace.JJ.AnimationController

animator:LoadAnimation(workspace.JJ.Animation):Play()

game:GetService("RunService").RenderStepped:Connect(function()
    for i, v in ipairs(eyes:GetDescendants()) do
        if v:IsA("MeshPart") then
            local eyePos = v.Position
            v.CFrame = CFrame.lookAt(eyePos, pHead.Position)
        end
    end
end)
#

at line 16, I also tried:

v.CFrame = CFrame.new(eyePos, pHead.Position)
#

which seemed to have the same result

grim belfry
#

I don't know if it's the best solution, but you can pretty easily replicate the effect using roblox physics

#

Instead of welding the eyes, keep them in place with an align position

#

and to save performance, you could just set an align orientation to look at the player as well, instead of setting it manually every frame

#

As long as the eyes are set to canCollide off, it shouldn't effect the position of the rest of the rig since it's completely separated from it when you use align position

grim belfry
#

If the eyes are rigged and have motor6ds, you could also use an ikcontroller

sinful bone
sinful bone
sinful bone
grim belfry
grim belfry
sinful bone
grim belfry
#

Could you send the script for it?

#

Also, make sure the eyes aren't welded to it

sinful bone
#

pardon if I sound a bit slow, im no expert in this field

grim belfry
#

If the eyes are rigged with motor6ds, they'll keep them in the sockets

sinful bone
grim belfry
#

No lol. IKcontrols depend entirely on motor6ds

sinful bone
# grim belfry Could you send the script for it?

yeah, but its pretty much just playing the animation, and then setting the IKControllers target

local JJ = workspace.JJ
local eyes = JJ.Parts.Eyes

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local pHead = character:WaitForChild("Head")

local animator = Instance.new("Animator")
animator.Parent = workspace.JJ.AnimationController

animator:LoadAnimation(workspace.JJ.Animation):Play()

local ikController = JJ.RootPart.IKControl
ikController.Target = pHead
grim belfry
#

Try setting the chain root and end effector both to the eye

sinful bone
#

tysm

grim belfry
#

Np

#

Gl with your game