Trying to get doors to stay with the elevator Y axis with their own Y axis

This commit is contained in:
2024-09-06 23:44:55 -04:00
parent 24d319a836
commit e0a9dd1178
2 changed files with 28 additions and 21 deletions

View File

@@ -64,12 +64,12 @@ local DoorsConfig: ElevatorTypes.DoorsConfig = {
Cab = { Cab = {
Type = DoorEnums.Door.DoubleSpeed, Type = DoorEnums.Door.DoubleSpeed,
Time = 4, Time = 4,
Goal = Vector3.new(4.027,0,0) Goal = Vector3.new(4.027,6.017)
}, },
Landing = { Landing = {
Type = DoorEnums.Door.SingleSpeed, Type = DoorEnums.Door.SingleSpeed,
Time = 4, Time = 4,
Goal = Vector3.new(4.221,0,0) Goal = Vector3.new(4.221)
} }
} }

View File

@@ -38,10 +38,6 @@ type Attributes = {
} }
} }
type Events = {
}
type Constructor_Return_Props = { type Constructor_Return_Props = {
DoorConfig: ElevatorEnums.DoorsConfig, DoorConfig: ElevatorEnums.DoorsConfig,
ElevatorBox: BasePart, ElevatorBox: BasePart,
@@ -119,17 +115,25 @@ function DoorAnimations.Cab.SingleSpeed(self, AnimationTime, Door1Position, Open
CabDoor1.Position = ElevatorY+CabDoor1.Position:Lerp(OpenToVec1+ElevatorDoor1_Goal, Algebra.Easing.OutQuad(AnimationTime)) CabDoor1.Position = ElevatorY+CabDoor1.Position:Lerp(OpenToVec1+ElevatorDoor1_Goal, Algebra.Easing.OutQuad(AnimationTime))
end end
-- local ElevatorBoxY = Vector3.new(0, self.ElevatorBox.Position.Y, 0)
-- local Door1Vector = Vector3.new(ElevatorDoor1_P.X, 0, ElevatorDoor1_P.Z)
-- local Door2Vector = Vector3.new(ElevatorDoor2_P.X, 0, ElevatorDoor2_P.Z)
-- self.ElevatorDoor1.Position = ElevatorBoxY+Door1Vector:Lerp(Door1Vector-Doors.Door1Stopped_X, Ease)
-- self.ElevatorDoor2.Position = ElevatorBoxY+Door2Vector:Lerp(Door2Vector-Doors.Door2Stopped_X, Ease)
@native @native
function DoorAnimations.Cab.DoubleSpeed(self, AnimationTime, Door1Position, Door2Position, OpenToVec1, OpenToVec2) function DoorAnimations.Cab.DoubleSpeed(self, AnimationTime, Door1Position, Door2Position, OpenToVec1, OpenToVec2)
local OutQuad = Algebra.Easing.OutQuad(AnimationTime) local OutQuad = Algebra.Easing.OutQuad(AnimationTime)
local ElevatorY = Vector3.new(0, self.ElevatorBox.Position.Y, 0) local ElevatorY = Vector3.new(0, self.ElevatorBox.Position.Y, 0)
local ElevatorDoor1_Goal = Vector3.new(OpenToVec1.X, OpenToVec1.Y, OpenToVec1.Z) local Door1XZ = Vector3.new(Door1Position.X, 0, Door1Position.Z)
local ElevatorDoor2_Goal = Vector3.new(OpenToVec2.X, OpenToVec2.Y, OpenToVec2.Z) local Door2XZ = Vector3.new(Door2Position.X, 0, Door2Position.Z)
local OpenToVec1XZ = Vector3.new(OpenToVec1.X, 0, OpenToVec1.Z)
local OpenToVec2XZ = Vector3.new(OpenToVec2.X, 0, OpenToVec2.Z)
local CabDoor1 = self.DoorsTree.Cab[1] :: BasePart local CabDoor1 = self.DoorsTree.Cab[1] :: BasePart
local CabDoor2 = self.DoorsTree.Cab[2] :: BasePart local CabDoor2 = self.DoorsTree.Cab[2] :: BasePart
CabDoor1.Position = Door1Position:Lerp(OpenToVec1, OutQuad) CabDoor1.Position = ElevatorY+Door1XZ:Lerp(Door1XZ+OpenToVec1XZ, OutQuad)
CabDoor2.Position = Door2Position:Lerp(OpenToVec2, OutQuad) CabDoor2.Position = ElevatorY+Door2XZ:Lerp(Door2XZ+OpenToVec2XZ, OutQuad)
end end
@native @native
@@ -156,7 +160,7 @@ function DoorAnimations.Landing.SingleSpeed(self, Floor, AnimationTime, Door1Pos
end end
--- ---
--Goofy ahh function --this is ridiculous optimization tech
local function OpenVecTuple(self: ClassConstructor, Opening: boolean, Type: DoorEnums.DoorLocationValues, HallFloor: number?): ...Vector3? local function OpenVecTuple(self: ClassConstructor, Opening: boolean, Type: DoorEnums.DoorLocationValues, HallFloor: number?): ...Vector3?
if Type == DoorEnums.DoorLocation.Landing and not HallFloor then if Type == DoorEnums.DoorLocation.Landing and not HallFloor then
warn("Hall/landing doors were called but no HallFloor number was received") warn("Hall/landing doors were called but no HallFloor number was received")
@@ -168,19 +172,21 @@ local function OpenVecTuple(self: ClassConstructor, Opening: boolean, Type: Door
if ConfType.Type == DoorEnums.Door.SingleSpeed then if ConfType.Type == DoorEnums.Door.SingleSpeed then
local P = (DoorsType[1] :: BasePart).Position local P = (DoorsType[1] :: BasePart).Position
local Direction = Opening and -ConfType.Goal or ConfType.Goal local Direction = Opening and -ConfType.Goal or ConfType.Goal
return table.unpack({ return table.unpack({
P, P,
P+Direction Direction
}) })
elseif ConfType.Type == DoorEnums.Door.DoubleSpeed then elseif ConfType.Type == DoorEnums.Door.DoubleSpeed then
local P = (DoorsType[1] :: BasePart).Position local P = (DoorsType[1] :: BasePart).Position
local P2 = (DoorsType[2] :: BasePart).Position local P2 = (DoorsType[2] :: BasePart).Position
local Direction = Opening and -ConfType.Goal or ConfType.Goal local Direction = Opening and -ConfType.Goal or ConfType.Goal
return table.unpack({ return table.unpack({
P, P,
P2, P2,
P+Direction, Direction,
P2+Direction/2 Direction/2
}) })
elseif ConfType.Type == DoorEnums.Door.TripleSpeed then elseif ConfType.Type == DoorEnums.Door.TripleSpeed then
--idk man --idk man
@@ -188,13 +194,14 @@ local function OpenVecTuple(self: ClassConstructor, Opening: boolean, Type: Door
local P2 = (DoorsType[2] :: BasePart).Position local P2 = (DoorsType[2] :: BasePart).Position
local P3 = (DoorsType[3] :: BasePart).Position local P3 = (DoorsType[3] :: BasePart).Position
local Direction = Opening and -ConfType.Goal or ConfType.Goal local Direction = Opening and -ConfType.Goal or ConfType.Goal
return table.unpack({ return table.unpack({
P, P,
P2, P2,
P3, P3,
P+Direction, Direction,
(P2+Direction)/1.5, Direction/1.5,
(P3+Direction)/2, Direction/2,
}) })
end end
return nil return nil
@@ -226,19 +233,19 @@ local function ToggleDoors(self: ClassConstructor, Type: DoorEnums.DoorLocationV
end end
function Doors:OpenCabAsync() function Doors:OpenCabAsync()
ToggleDoors(self, DoorEnums.DoorLocation.Cab, true) return ToggleDoors(self, DoorEnums.DoorLocation.Cab, true)
end end
function Doors:CloseCabAsync() function Doors:CloseCabAsync()
ToggleDoors(self, DoorEnums.DoorLocation.Cab, false) return ToggleDoors(self, DoorEnums.DoorLocation.Cab, false)
end end
function Doors:CloseAtFloorAsync(Floor) function Doors:CloseAtFloorAsync(Floor)
ToggleDoors(self, DoorEnums.DoorLocation.Landing, false, Floor) return ToggleDoors(self, DoorEnums.DoorLocation.Landing, false, Floor)
end end
function Doors:OpenAtFloorAsync(Floor) function Doors:OpenAtFloorAsync(Floor)
ToggleDoors(self, DoorEnums.DoorLocation.Landing, true, Floor) return ToggleDoors(self, DoorEnums.DoorLocation.Landing, true, Floor)
end end
return Doors return Doors