I am attempting to get this cupcake to look at me wherever I go. I have the eyes in a model, so that they can pivot on the Y axis with the head, and then I have the script adjust the XZ axis of each eye individually. This is because I plan to slow down the tracking of the head of the cupcake so that the eyes will look at the player while the cupcakes head tries to keep up, making it look a bit more realistic.
#Eye tracking is offset by 90 degrees?
1 messages · Page 1 of 1 (latest)
This script is managing multiple head trackings, so dont mind.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local pHead = character:WaitForChild("Head")
----------- MAIN LOOP -------------
game:GetService("RunService").RenderStepped:Connect(function()
local targetPos = pHead.Position
-- SHADOW FREDDY --
local shadowFreddy = workspace.Map.Map:WaitForChild("shadowFreddyPAS")
local sFHead = shadowFreddy.up:WaitForChild("head")
local sFHeadPivot = sFHead:GetPivot()
local sFHeadPos = sFHeadPivot.Position
local sFFollow = CFrame.lookAt(sFHeadPos, targetPos, Vector3.new(0,1,0))
sFHead:PivotTo(sFFollow)
-- GIANT CUPCAKE --
--Head--
local cupcake = workspace.Map.Map:WaitForChild("giantCupcake")
local gCHead = cupcake:WaitForChild("Head")
local gCHeadPivot = gCHead:GetPivot()
local gCHeadPos = gCHeadPivot.Position
local targetY = Vector3.new(targetPos.X, gCHeadPos.Y, targetPos.Z)
local gCFollow = CFrame.lookAt(gCHeadPos, targetY, Vector3.new(0,1,0))
gCHead:PivotTo(gCFollow)
--Eyes--
local gCEyes = cupcake.Head:WaitForChild("Eyes")
local gCEyePivot = gCEyes:GetPivot()
local gCEyePos = gCEyePivot.Position
local EyetargetY = Vector3.new(targetPos.X, gCHeadPos.Y, targetPos.Z)
gCEyes:PivotTo(gCFollow)
for _, eye in ipairs(gCEyes:GetChildren()) do
if eye.Name ~= "PrimaryEyes" then
local eyePos = eye.Position
local eyeTargetXZ = Vector3.new(targetPos.X, gCEyePos.Y, targetPos.Z)
local eyeFollow = CFrame.lookAt(eyePos, eyeTargetXZ, Vector3.new(0,1,0))
eye.CFrame = eyeFollow
end
end
end)
cant you just make the eyes track the player on the client so its looking at the correct player for everyone
** You are now Level 8! **
its js a cframe.new(eyeposition,playerposition)
LOL
geeked in the clouds
Thats what im trying to do, I just couldnt figure it out so i resorted to that method
is the front of the eye where the pupil is? like in the part
?
It should just be a loop and one line basically
Or two cause of two eyes
Is the decal just on the wrong face or something
Wym by 90 offset
ohhh it isnt, how can I fix that?
try this, check if the decal is on the wrong face
make it so that the pupil matches where the front of the part is
its just a mesh wtih a texture
hmm
you might have to re export it with the right rotation then, but im not 100% sure
i was able to remove the texture from the mesh, and add a decal usiing the texture ID. I just rotated the eye and moved the texture to the front
nice, does it work now?
yeah, but im not sure how to achieve that delayed head movement
ohhh ok