Hi all, I’ve been searching for a solution to this issue for some time now but couldn’t find anything. Basically I’m trying to make a bowling ball rotate along 2 parameters (Axis Tilt, and Axis Rotation) but can not successfully get this effect. I am assuming that this is a gimbal lock type equation that must be used. Below is a video of what I am trying to achieve, and the code that I currently have. Note that I do not need the sliders, I just need to axis tilt and axis rotation to be adjustable and roll along those parameters.
local axisTilt = 0
local axisRotation = 80
function changeTilt()
local newText = axisInput.TextBox.Text
local finalizedNumber = 0
if tonumber(newText) then
finalizedNumber = math.clamp(newText, -20, 20)
end
axisInput.TextBox.Text = finalizedNumber
axisVisual.TiltVisual.Ball.Orientation = Vector3.new(0, 0, finalizedNumber)
axisVisual.TiltVisual.Axis.Orientation = Vector3.new(0, 0, finalizedNumber)
axisTilt = finalizedNumber
InventoryService:TweakRelease(axisTilt, axisRotation)
end
axisInput.TextBox.FocusLost:Connect(changeTilt)
function changeRotation()
local newText = rotationInput.TextBox.Text
local finalizedNumber = 0
if tonumber(newText) then
finalizedNumber = math.clamp(newText, 0, 85)
end
rotationInput.TextBox.Text = finalizedNumber
axisRotation = finalizedNumber
InventoryService:TweakRelease(axisTilt, axisRotation)
end
rotationInput.TextBox.FocusLost:Connect(changeRotation)
function spinBall()
local rollAxis = Vector3.new(1, 0, 0)
Ball.CFrame = Ball.CFrame:ToWorldSpace(CFrame.Angles(axisTilt, axisRotation, 0))
Ball.CFrame = Ball.CFrame * CFrame.fromAxisAngle(rollAxis, -0.3)
end
type or paste code here