Hello everyone,
I want to animate a first-class seat for a project, but I’m having trouble making it recline fully. Since it has to be able to recline and turn into a lie-flat bed, I first finished the recline function, which worked well. I used the Motor6D’s C1 function to move the seat forward and used the DesiredAngle function to recline the seat back. To do this, I used a part with a motor at the point where I wanted to move the seat to rotate the seat back.
However, when I tried to do this again, but at the place the seat moves to lie flat, it doesn’t work. Only the seat base moves and the seat back stays frozen. I figured this is because the seat back is affected by multiple Motor6D’s, but I don’t know an alternative to make the seat able to both recline partially and lie flat.
Here’s my script, if that helps.
local bmotor = script.Parent.Parent.C.Back
local smotor = script.Parent.Seat
local fmotor = script.Parent.Parent.E.Back
local isReclined = false
local isBed = false
local isMoving = false
task.wait(5)
function recline()
if isReclined == false and isMoving == false then
if isBed == true then
isMoving = true
for i = 1, 160 do
bmotor.C1 = bmotor.C1 * CFrame.new(-0.010,0,0)
smotor.C1 = smotor.C1 * CFrame.new(-0.010,0,0)
task.wait(0.01)
end
bmotor.DesiredAngle = -0.4
isReclined = true
task.wait(2)
isMoving = false
isReclined = true
isBed = false
elseif isBed == false then
isMoving = true
for i = 1, 160 do
bmotor.C1 = bmotor.C1 * CFrame.new(0.010,0,0)
smotor.C1 = smotor.C1 * CFrame.new(0.010,0,0)
task.wait(0.01)
end
bmotor.DesiredAngle = -0.4
isReclined = true
task.wait(2)
isMoving = false
isBed = false
isReclined = true
end
elseif isReclined == true and isMoving == false then
isMoving = true
bmotor.DesiredAngle = 0
for i = 1, (400/3) do
bmotor.C1 = bmotor.C1 * CFrame.new(-0.010,0,0)
smotor.C1 = smotor.C1 * CFrame.new(-0.010,0,0)
task.wait(0.01)
end
isReclined = false
task.wait(2)
isMoving = false
end
end
function bed()
if isBed == false and isMoving == false then
if isReclined == true then
isMoving = true
for i = 1, 160 do
bmotor.C1 = bmotor.C1 * CFrame.new(0.010,0,0)
smotor.C1 = smotor.C1 * CFrame.new(0.010,0,0)
task.wait(0.01)
end
fmotor.DesiredAngle = -1.4
task.wait(2)
isMoving = false
isBed = true
isReclined = false
elseif isReclined == false then
isMoving = true
for i = 1, 320 do
bmotor.C1 = bmotor.C1 * CFrame.new(0.010,0,0)
smotor.C1 = smotor.C1 * CFrame.new(0.010,0,0)
task.wait(0.01)
end
fmotor.DesiredAngle = -1.4
task.wait(2)
isMoving = false
isBed = true
isReclined = false
end
elseif isBed == true and isMoving == false then
isMoving = true
fmotor.DesiredAngle = 0
for i = 1, (400/3) do
bmotor.C1 = bmotor.C1 * CFrame.new(-0.010,0,0)
smotor.C1 = smotor.C1 * CFrame.new(-0.010,0,0)
task.wait(0.01)
end
isReclined = false
task.wait(2)
isMoving = false
end
end
recline()
task.wait(5)
bed()
print("Done!")
Here’s my setup:
If anyone has information on how to fix this problem, that would be great. Anything is appreciated. Thanks in advance!