I don’t usually run to the devforum but I’ll keep it quick.
I am not a wizard at CFrames, never have been.
I want my NPC / Part if you want to think about it as a part go ahead, no difference.
To spin on its local y axis and local x axis
I have my numbers and etc.
--// this is outside
local defCF = part.CFrame --// before the loop
--// this is in a runservice loop btw
local startCF = CFrame.new(part.Position)
local lookAtCF = defCF.Rotation
part.CFrame = startCF
* lookAtCF
* CFrame.Angles(math.rad(sineX), math.rad(sineY), 0)
However, what happens is the sineX suddenly behaves like its moving him on his local Z and forward and back? I’ve got no idea what is going on so I urge you any CFrame wizards out there please do help.
He shouldn’t be facing towards global north, he should just be facing the direction stored in DEFCF and rotating with the numbers with that dir in mind
local startCF = CFrame.new(part.Position)
local lookAtCF = defCF.Rotation
-- Apply rotations around local Y and X axes
part.CFrame = startCF
* lookAtCF
* CFrame.Angles(math.rad(sineX), 0, 0) -- X axis
* CFrame.Angles(0, math.rad(sineY), 0) -- Y axis
I have tried separating the rotations into two CFrame.Angles, can you try the script?
--// this is outside
local defCF = part.CFrame --// before the loop
--// this is in a runservice loop btw
local startCF = CFrame.new(part.Position)
local lookAtCF = defCF - defCF.Position
part.CFrame = startCF
* lookAtCF
* CFrame.Angles(math.rad(sineX), 0, 0) -- X axis
* CFrame.Angles(0, math.rad(sineY), 0) -- Y axis
ok so my own code is affecting itself, its updating its position for no reason.
apparantley its moving itself for some weirdddd reason after its applied each frame