To improve my skills I was working on a small project similar to “Keep Talking and Nobody Explodes”. I got the explosive rotating, however it won’t always rotate the same up and down.
Notice how it tilts differently from a different angle, even though I moved my mouse the same way each time.
My code for changing the explosive’s cframe is fairly short:
local change = (mousePos - lastMousePos)/5
local currentCFrame = currentExplosive:GetPrimaryPartCFrame()
local angles = CFrame.Angles( -math.rad(change.Y), math.rad(change.X), 0 )
setCF(currentCFrame * angles)
Please note that it has nothing to do with “setCF”! setCF is just a shorter version of “model:SetPrimaryPartCFrame()”.
Any ideas on why this happens? I have a good feeling that its some simple cframe math to fix it.
I’m still kind of confused… what would I have to change about my current multiplication to achieve this result? Do I multiple angles by currentCFrame and then add that result’s rotation to the explosive’s position?