i’m trying to make a tidally locked moon, and I want to use CFrame.lookAlong to have it always facing the parent planet. However, it flips over every 180 degrees, and I have no clue how to solve this
there seems to be no issues with my line of code, this was also a problem in the past where CFrame.lookAt was doing the same thing, except just instantly snapping upside down.
hmmm, what if you normalize the second parameter (center) lookAlong’s second parameter takes a direction, what happens if you do:
center.Unit -- this probably won't work
local direction = (planetBeingOrbited.Position - moon.Position).Unit
-- you might have to flip the vectors that are being subtracted, i could've done it the other way around
CFrame.lookAlong(moon.Pos, direction, whateverHere)
CFraming at exact 90° angles can lead to gimbal lock of the axes. Basically when your rotation ends up being exactly 90° one of the x, y or z axes align exactly with one of the others causing object to flip around like that.
Search ‘gimbal lock’ in the forums for explanations and Solved posts about it because it’s above my ability to fix it.
This is erroneous. the second argument expects a look vector - some direction vector that the cframe tries to copy. while remaining in location.
If you want it to perpetually look at something, you should be using CFrame.LookAt.
(CFrame.lookAlong is not a good method to be honest. yet to find a usecase for it.)