#Override one part of an animation's CFrame?
1 messages · Page 1 of 1 (latest)
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
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
^
If the eyes are rigged and have motor6ds, you could also use an ikcontroller
yeah, i plan to have this only working in a specific zone to save performance anyway, this is just to get it working.
They are rigged to the head, but for some reason in my model the pupils are seperate from the eyeballs, so I have them welded together which is why it gets the descendants rather than just each eye. I have never used an IKController. Do you think you could hlep meout with that, or send me a documentation of it that would help me out?
which is why I think this wouldnt work, because I would somehow have to keep the pupils on the eye
Just weld the pupil to the eye
Only the actual eyes would need to be disconnected from the main rig for this to work. Anything attached to the eyes can keep their welds
Im attempting to use the IKControls to have the right eyes target (just for testing) to be "pHead" or the players head, but it seems to not do anything and the eye stays stuck to the animation.
how will the eyes follow the rotation of the head as show in the video tho?
pardon if I sound a bit slow, im no expert in this field

If the eyes are rigged with motor6ds, they'll keep them in the sockets
ohhh, i thought u meant to not use motor6ds at all, disregard what I said
No lol. IKcontrols depend entirely on motor6ds
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
Try setting the chain root and end effector both to the eye
ayee works like an absolute charm
tysm