mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
Trying to get doors to stay with the elevator Y axis with their own Y axis
This commit is contained in:
@@ -64,12 +64,12 @@ local DoorsConfig: ElevatorTypes.DoorsConfig = {
|
||||
Cab = {
|
||||
Type = DoorEnums.Door.DoubleSpeed,
|
||||
Time = 4,
|
||||
Goal = Vector3.new(4.027,0,0)
|
||||
Goal = Vector3.new(4.027,6.017)
|
||||
},
|
||||
Landing = {
|
||||
Type = DoorEnums.Door.SingleSpeed,
|
||||
Time = 4,
|
||||
Goal = Vector3.new(4.221,0,0)
|
||||
Goal = Vector3.new(4.221)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +38,6 @@ type Attributes = {
|
||||
}
|
||||
}
|
||||
|
||||
type Events = {
|
||||
|
||||
}
|
||||
|
||||
type Constructor_Return_Props = {
|
||||
DoorConfig: ElevatorEnums.DoorsConfig,
|
||||
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))
|
||||
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
|
||||
function DoorAnimations.Cab.DoubleSpeed(self, AnimationTime, Door1Position, Door2Position, OpenToVec1, OpenToVec2)
|
||||
local OutQuad = Algebra.Easing.OutQuad(AnimationTime)
|
||||
local ElevatorY = Vector3.new(0, self.ElevatorBox.Position.Y, 0)
|
||||
local ElevatorDoor1_Goal = Vector3.new(OpenToVec1.X, OpenToVec1.Y, OpenToVec1.Z)
|
||||
local ElevatorDoor2_Goal = Vector3.new(OpenToVec2.X, OpenToVec2.Y, OpenToVec2.Z)
|
||||
local Door1XZ = Vector3.new(Door1Position.X, 0, Door1Position.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 CabDoor2 = self.DoorsTree.Cab[2] :: BasePart
|
||||
|
||||
CabDoor1.Position = Door1Position:Lerp(OpenToVec1, OutQuad)
|
||||
CabDoor2.Position = Door2Position:Lerp(OpenToVec2, OutQuad)
|
||||
CabDoor1.Position = ElevatorY+Door1XZ:Lerp(Door1XZ+OpenToVec1XZ, OutQuad)
|
||||
CabDoor2.Position = ElevatorY+Door2XZ:Lerp(Door2XZ+OpenToVec2XZ, OutQuad)
|
||||
end
|
||||
|
||||
@native
|
||||
@@ -156,7 +160,7 @@ function DoorAnimations.Landing.SingleSpeed(self, Floor, AnimationTime, Door1Pos
|
||||
end
|
||||
---
|
||||
|
||||
--Goofy ahh function
|
||||
--this is ridiculous optimization tech
|
||||
local function OpenVecTuple(self: ClassConstructor, Opening: boolean, Type: DoorEnums.DoorLocationValues, HallFloor: number?): ...Vector3?
|
||||
if Type == DoorEnums.DoorLocation.Landing and not HallFloor then
|
||||
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
|
||||
local P = (DoorsType[1] :: BasePart).Position
|
||||
local Direction = Opening and -ConfType.Goal or ConfType.Goal
|
||||
|
||||
return table.unpack({
|
||||
P,
|
||||
P+Direction
|
||||
Direction
|
||||
})
|
||||
elseif ConfType.Type == DoorEnums.Door.DoubleSpeed then
|
||||
local P = (DoorsType[1] :: BasePart).Position
|
||||
local P2 = (DoorsType[2] :: BasePart).Position
|
||||
local Direction = Opening and -ConfType.Goal or ConfType.Goal
|
||||
|
||||
return table.unpack({
|
||||
P,
|
||||
P2,
|
||||
P+Direction,
|
||||
P2+Direction/2
|
||||
Direction,
|
||||
Direction/2
|
||||
})
|
||||
elseif ConfType.Type == DoorEnums.Door.TripleSpeed then
|
||||
--idk man
|
||||
@@ -188,13 +194,14 @@ local function OpenVecTuple(self: ClassConstructor, Opening: boolean, Type: Door
|
||||
local P2 = (DoorsType[2] :: BasePart).Position
|
||||
local P3 = (DoorsType[3] :: BasePart).Position
|
||||
local Direction = Opening and -ConfType.Goal or ConfType.Goal
|
||||
|
||||
return table.unpack({
|
||||
P,
|
||||
P2,
|
||||
P3,
|
||||
P+Direction,
|
||||
(P2+Direction)/1.5,
|
||||
(P3+Direction)/2,
|
||||
Direction,
|
||||
Direction/1.5,
|
||||
Direction/2,
|
||||
})
|
||||
end
|
||||
return nil
|
||||
@@ -226,19 +233,19 @@ local function ToggleDoors(self: ClassConstructor, Type: DoorEnums.DoorLocationV
|
||||
end
|
||||
|
||||
function Doors:OpenCabAsync()
|
||||
ToggleDoors(self, DoorEnums.DoorLocation.Cab, true)
|
||||
return ToggleDoors(self, DoorEnums.DoorLocation.Cab, true)
|
||||
end
|
||||
|
||||
function Doors:CloseCabAsync()
|
||||
ToggleDoors(self, DoorEnums.DoorLocation.Cab, false)
|
||||
return ToggleDoors(self, DoorEnums.DoorLocation.Cab, false)
|
||||
end
|
||||
|
||||
function Doors:CloseAtFloorAsync(Floor)
|
||||
ToggleDoors(self, DoorEnums.DoorLocation.Landing, false, Floor)
|
||||
return ToggleDoors(self, DoorEnums.DoorLocation.Landing, false, Floor)
|
||||
end
|
||||
|
||||
function Doors:OpenAtFloorAsync(Floor)
|
||||
ToggleDoors(self, DoorEnums.DoorLocation.Landing, true, Floor)
|
||||
return ToggleDoors(self, DoorEnums.DoorLocation.Landing, true, Floor)
|
||||
end
|
||||
|
||||
return Doors
|
||||
Reference in New Issue
Block a user