@rbxts/gravity-controller 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GravityController.rbxmx +761 -647
- package/out/index.d.ts +13 -1
- package/out/init.lua +7 -1
- package/package.json +1 -1
package/GravityController.rbxmx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
<roblox version="4">
|
|
2
|
-
<Item class="Script" referent="0">
|
|
3
|
-
<Properties>
|
|
4
|
-
<string name="Name">GravityController</string>
|
|
5
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
6
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
7
|
-
<bool name="Disabled">false</bool>
|
|
8
|
-
<Content name="LinkedSource">
|
|
9
|
-
<null>
|
|
10
|
-
</null>
|
|
11
|
-
</Content>
|
|
12
|
-
<token name="RunContext">0</token>
|
|
1
|
+
<roblox version="4">
|
|
2
|
+
<Item class="Script" referent="0">
|
|
3
|
+
<Properties>
|
|
4
|
+
<string name="Name">GravityController</string>
|
|
5
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
6
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
7
|
+
<bool name="Disabled">false</bool>
|
|
8
|
+
<Content name="LinkedSource">
|
|
9
|
+
<null>
|
|
10
|
+
</null>
|
|
11
|
+
</Content>
|
|
12
|
+
<token name="RunContext">0</token>
|
|
13
13
|
<string name="Source">local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
14
14
|
local StarterPlayerScripts = game:GetService("StarterPlayer"):WaitForChild("StarterPlayerScripts")
|
|
15
15
|
local StarterCharacterScripts = game:GetService("StarterPlayer"):WaitForChild("StarterCharacterScripts")
|
|
@@ -26,42 +26,42 @@ replace(Client:WaitForChild("PlayerScriptsLoader"), StarterPlayerScripts)
|
|
|
26
26
|
replace(Client:WaitForChild("RbxCharacterSounds"), StarterPlayerScripts)
|
|
27
27
|
replace(Client:WaitForChild("Animate"), StarterCharacterScripts)
|
|
28
28
|
|
|
29
|
-
script:WaitForChild("GravityController").Parent = ReplicatedStorage</string>
|
|
30
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
31
|
-
<BinaryString name="Tags"></BinaryString>
|
|
32
|
-
</Properties>
|
|
33
|
-
<Item class="Folder" referent="1">
|
|
34
|
-
<Properties>
|
|
35
|
-
<string name="Name">Client</string>
|
|
36
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
37
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
38
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
39
|
-
<BinaryString name="Tags"></BinaryString>
|
|
40
|
-
</Properties>
|
|
41
|
-
<Item class="LocalScript" referent="2">
|
|
42
|
-
<Properties>
|
|
43
|
-
<string name="Name">Animate</string>
|
|
44
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
45
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
46
|
-
<bool name="Disabled">false</bool>
|
|
47
|
-
<Content name="LinkedSource">
|
|
48
|
-
<null>
|
|
49
|
-
</null>
|
|
50
|
-
</Content>
|
|
51
|
-
<token name="RunContext">0</token>
|
|
52
|
-
<string name="Source">require(script:WaitForChild("Controller"))</string>
|
|
53
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
54
|
-
<BinaryString name="Tags"></BinaryString>
|
|
55
|
-
</Properties>
|
|
56
|
-
<Item class="ModuleScript" referent="3">
|
|
57
|
-
<Properties>
|
|
58
|
-
<string name="Name">Controller</string>
|
|
59
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
60
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
61
|
-
<Content name="LinkedSource">
|
|
62
|
-
<null>
|
|
63
|
-
</null>
|
|
64
|
-
</Content>
|
|
29
|
+
script:WaitForChild("GravityController").Parent = ReplicatedStorage</string>
|
|
30
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
31
|
+
<BinaryString name="Tags"></BinaryString>
|
|
32
|
+
</Properties>
|
|
33
|
+
<Item class="Folder" referent="1">
|
|
34
|
+
<Properties>
|
|
35
|
+
<string name="Name">Client</string>
|
|
36
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
37
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
38
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
39
|
+
<BinaryString name="Tags"></BinaryString>
|
|
40
|
+
</Properties>
|
|
41
|
+
<Item class="LocalScript" referent="2">
|
|
42
|
+
<Properties>
|
|
43
|
+
<string name="Name">Animate</string>
|
|
44
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
45
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
46
|
+
<bool name="Disabled">false</bool>
|
|
47
|
+
<Content name="LinkedSource">
|
|
48
|
+
<null>
|
|
49
|
+
</null>
|
|
50
|
+
</Content>
|
|
51
|
+
<token name="RunContext">0</token>
|
|
52
|
+
<string name="Source">require(script:WaitForChild("Controller"))</string>
|
|
53
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
54
|
+
<BinaryString name="Tags"></BinaryString>
|
|
55
|
+
</Properties>
|
|
56
|
+
<Item class="ModuleScript" referent="3">
|
|
57
|
+
<Properties>
|
|
58
|
+
<string name="Name">Controller</string>
|
|
59
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
60
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
61
|
+
<Content name="LinkedSource">
|
|
62
|
+
<null>
|
|
63
|
+
</null>
|
|
64
|
+
</Content>
|
|
65
65
|
<string name="Source">local animate = script.Parent
|
|
66
66
|
local humanoid = animate.Parent:WaitForChild("Humanoid")
|
|
67
67
|
local loaded = animate:WaitForChild("Loaded")
|
|
@@ -77,39 +77,39 @@ end
|
|
|
77
77
|
|
|
78
78
|
loaded.Value = true
|
|
79
79
|
|
|
80
|
-
return output</string>
|
|
81
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
82
|
-
<BinaryString name="Tags"></BinaryString>
|
|
83
|
-
</Properties>
|
|
84
|
-
</Item>
|
|
85
|
-
<Item class="BoolValue" referent="4">
|
|
86
|
-
<Properties>
|
|
87
|
-
<string name="Name">Loaded</string>
|
|
88
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
89
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
90
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
91
|
-
<BinaryString name="Tags"></BinaryString>
|
|
92
|
-
<bool name="Value">false</bool>
|
|
93
|
-
</Properties>
|
|
94
|
-
</Item>
|
|
95
|
-
<Item class="BindableFunction" referent="5">
|
|
96
|
-
<Properties>
|
|
97
|
-
<string name="Name">PlayEmote</string>
|
|
98
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
99
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
100
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
101
|
-
<BinaryString name="Tags"></BinaryString>
|
|
102
|
-
</Properties>
|
|
103
|
-
</Item>
|
|
104
|
-
<Item class="ModuleScript" referent="6">
|
|
105
|
-
<Properties>
|
|
106
|
-
<string name="Name">R15</string>
|
|
107
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
108
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
109
|
-
<Content name="LinkedSource">
|
|
110
|
-
<null>
|
|
111
|
-
</null>
|
|
112
|
-
</Content>
|
|
80
|
+
return output</string>
|
|
81
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
82
|
+
<BinaryString name="Tags"></BinaryString>
|
|
83
|
+
</Properties>
|
|
84
|
+
</Item>
|
|
85
|
+
<Item class="BoolValue" referent="4">
|
|
86
|
+
<Properties>
|
|
87
|
+
<string name="Name">Loaded</string>
|
|
88
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
89
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
90
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
91
|
+
<BinaryString name="Tags"></BinaryString>
|
|
92
|
+
<bool name="Value">false</bool>
|
|
93
|
+
</Properties>
|
|
94
|
+
</Item>
|
|
95
|
+
<Item class="BindableFunction" referent="5">
|
|
96
|
+
<Properties>
|
|
97
|
+
<string name="Name">PlayEmote</string>
|
|
98
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
99
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
100
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
101
|
+
<BinaryString name="Tags"></BinaryString>
|
|
102
|
+
</Properties>
|
|
103
|
+
</Item>
|
|
104
|
+
<Item class="ModuleScript" referent="6">
|
|
105
|
+
<Properties>
|
|
106
|
+
<string name="Name">R15</string>
|
|
107
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
108
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
109
|
+
<Content name="LinkedSource">
|
|
110
|
+
<null>
|
|
111
|
+
</null>
|
|
112
|
+
</Content>
|
|
113
113
|
<string name="Source"><![CDATA[local script = script.Parent
|
|
114
114
|
|
|
115
115
|
local Character = script.Parent
|
|
@@ -932,20 +932,20 @@ return {
|
|
|
932
932
|
onUnhook = onUnhook
|
|
933
933
|
}
|
|
934
934
|
|
|
935
|
-
]]></string>
|
|
936
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
937
|
-
<BinaryString name="Tags"></BinaryString>
|
|
938
|
-
</Properties>
|
|
939
|
-
</Item>
|
|
940
|
-
<Item class="ModuleScript" referent="7">
|
|
941
|
-
<Properties>
|
|
942
|
-
<string name="Name">R6</string>
|
|
943
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
944
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
945
|
-
<Content name="LinkedSource">
|
|
946
|
-
<null>
|
|
947
|
-
</null>
|
|
948
|
-
</Content>
|
|
935
|
+
]]></string>
|
|
936
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
937
|
+
<BinaryString name="Tags"></BinaryString>
|
|
938
|
+
</Properties>
|
|
939
|
+
</Item>
|
|
940
|
+
<Item class="ModuleScript" referent="7">
|
|
941
|
+
<Properties>
|
|
942
|
+
<string name="Name">R6</string>
|
|
943
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
944
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
945
|
+
<Content name="LinkedSource">
|
|
946
|
+
<null>
|
|
947
|
+
</null>
|
|
948
|
+
</Content>
|
|
949
949
|
<string name="Source">local script = script.Parent
|
|
950
950
|
|
|
951
951
|
local Figure = script.Parent
|
|
@@ -1525,30 +1525,30 @@ return {
|
|
|
1525
1525
|
onPlatformStanding = onPlatformStanding,
|
|
1526
1526
|
onHook = onHook,
|
|
1527
1527
|
onUnhook = onUnhook
|
|
1528
|
-
}</string>
|
|
1529
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
1530
|
-
<BinaryString name="Tags"></BinaryString>
|
|
1531
|
-
</Properties>
|
|
1532
|
-
</Item>
|
|
1533
|
-
<Item class="ObjectValue" referent="8">
|
|
1534
|
-
<Properties>
|
|
1535
|
-
<string name="Name">ReplicatedHumanoid</string>
|
|
1536
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1537
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
1538
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
1539
|
-
<BinaryString name="Tags"></BinaryString>
|
|
1540
|
-
<Ref name="Value">null</Ref>
|
|
1541
|
-
</Properties>
|
|
1542
|
-
</Item>
|
|
1543
|
-
<Item class="ModuleScript" referent="9">
|
|
1544
|
-
<Properties>
|
|
1545
|
-
<string name="Name">VerifyAnims</string>
|
|
1546
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1547
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
1548
|
-
<Content name="LinkedSource">
|
|
1549
|
-
<null>
|
|
1550
|
-
</null>
|
|
1551
|
-
</Content>
|
|
1528
|
+
}</string>
|
|
1529
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
1530
|
+
<BinaryString name="Tags"></BinaryString>
|
|
1531
|
+
</Properties>
|
|
1532
|
+
</Item>
|
|
1533
|
+
<Item class="ObjectValue" referent="8">
|
|
1534
|
+
<Properties>
|
|
1535
|
+
<string name="Name">ReplicatedHumanoid</string>
|
|
1536
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1537
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
1538
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
1539
|
+
<BinaryString name="Tags"></BinaryString>
|
|
1540
|
+
<Ref name="Value">null</Ref>
|
|
1541
|
+
</Properties>
|
|
1542
|
+
</Item>
|
|
1543
|
+
<Item class="ModuleScript" referent="9">
|
|
1544
|
+
<Properties>
|
|
1545
|
+
<string name="Name">VerifyAnims</string>
|
|
1546
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1547
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
1548
|
+
<Content name="LinkedSource">
|
|
1549
|
+
<null>
|
|
1550
|
+
</null>
|
|
1551
|
+
</Content>
|
|
1552
1552
|
<string name="Source">local LENGTH = string.len("Animation")
|
|
1553
1553
|
|
|
1554
1554
|
local DESC_ANIM_PROPS = {
|
|
@@ -1574,376 +1574,376 @@ return function(humanoid, animate)
|
|
|
1574
1574
|
animate:WaitForChild(lookFor)
|
|
1575
1575
|
end
|
|
1576
1576
|
end
|
|
1577
|
-
end</string>
|
|
1578
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
1579
|
-
<BinaryString name="Tags"></BinaryString>
|
|
1580
|
-
</Properties>
|
|
1581
|
-
</Item>
|
|
1582
|
-
</Item>
|
|
1583
|
-
<Item class="LocalScript" referent="10">
|
|
1584
|
-
<Properties>
|
|
1585
|
-
<string name="Name">PlayerScriptsLoader</string>
|
|
1586
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1587
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
1588
|
-
<bool name="Disabled">false</bool>
|
|
1589
|
-
<Content name="LinkedSource">
|
|
1590
|
-
<null>
|
|
1591
|
-
</null>
|
|
1592
|
-
</Content>
|
|
1593
|
-
<token name="RunContext">0</token>
|
|
1594
|
-
<string name="Source">--[[
|
|
1595
|
-
PlayerScriptsLoader - This script requires and instantiates the PlayerModule singleton
|
|
1596
|
-
|
|
1597
|
-
2018 PlayerScripts Update - AllYourBlox
|
|
1598
|
-
2020 CameraModule Public Access Override & modifications - EgoMoose
|
|
1599
|
-
--]]
|
|
1600
|
-
|
|
1601
|
-
local MIN_Y = math.rad(-80)
|
|
1602
|
-
local MAX_Y = math.rad(80)
|
|
1603
|
-
local ZERO3 = Vector3.new(0, 0, 0)
|
|
1604
|
-
|
|
1605
|
-
local PlayerModule = script.Parent:WaitForChild("PlayerModule")
|
|
1606
|
-
local CameraInjector = script:WaitForChild("CameraInjector")
|
|
1607
|
-
|
|
1608
|
-
require(CameraInjector)
|
|
1609
|
-
|
|
1610
|
-
-- Control Modifications
|
|
1611
|
-
|
|
1612
|
-
local Control = require(PlayerModule:WaitForChild("ControlModule"))
|
|
1613
|
-
local TouchJump = require(PlayerModule.ControlModule:WaitForChild("TouchJump"))
|
|
1614
|
-
|
|
1615
|
-
function Control:IsJumping()
|
|
1616
|
-
if self.activeController then
|
|
1617
|
-
return self.activeController:GetIsJumping()
|
|
1618
|
-
or (self.touchJumpController and self.touchJumpController:GetIsJumping())
|
|
1619
|
-
end
|
|
1620
|
-
return false
|
|
1621
|
-
end
|
|
1622
|
-
|
|
1623
|
-
local oldEnabled = TouchJump.UpdateEnabled
|
|
1624
|
-
|
|
1625
|
-
function TouchJump:UpdateEnabled()
|
|
1626
|
-
self.jumpStateEnabled = true
|
|
1627
|
-
oldEnabled(self)
|
|
1628
|
-
end
|
|
1629
|
-
|
|
1630
|
-
-- Camera Modifications
|
|
1631
|
-
|
|
1632
|
-
local CameraModule = PlayerModule:WaitForChild("CameraModule")
|
|
1633
|
-
|
|
1634
|
-
local UserSettings = require(script:WaitForChild("FakeUserSettings"))
|
|
1635
|
-
local UserGameSettings = UserSettings():GetService("UserGameSettings")
|
|
1636
|
-
|
|
1637
|
-
local FFlagUserFlagEnableNewVRSystem = UserSettings():SafeIsUserFeatureEnabled("UserFlagEnableNewVRSystem")
|
|
1638
|
-
|
|
1639
|
-
-- Camera variables
|
|
1640
|
-
|
|
1641
|
-
local transitionRate = 0.15
|
|
1642
|
-
local upVector = Vector3.new(0, 1, 0)
|
|
1643
|
-
local upCFrame = CFrame.new()
|
|
1644
|
-
|
|
1645
|
-
local spinPart = workspace.Terrain
|
|
1646
|
-
local prevSpinPart = spinPart
|
|
1647
|
-
local prevSpinCFrame = spinPart.CFrame
|
|
1648
|
-
local twistCFrame = CFrame.new()
|
|
1649
|
-
|
|
1650
|
-
-- Camera Utilities
|
|
1651
|
-
|
|
1652
|
-
local Utils = require(CameraModule:WaitForChild("CameraUtils"))
|
|
1653
|
-
|
|
1654
|
-
function Utils.GetAngleBetweenXZVectors(v1, v2)
|
|
1655
|
-
v1 = upCFrame:VectorToObjectSpace(v1)
|
|
1656
|
-
v2 = upCFrame:VectorToObjectSpace(v2)
|
|
1657
|
-
return math.atan2(v2.X*v1.Z-v2.Z*v1.X, v2.X*v1.X+v2.Z*v1.Z)
|
|
1658
|
-
end
|
|
1659
|
-
|
|
1660
|
-
-- Popper Camera
|
|
1661
|
-
|
|
1662
|
-
local Poppercam = require(CameraModule:WaitForChild("Poppercam"))
|
|
1663
|
-
local ZoomController = require(CameraModule:WaitForChild("ZoomController"))
|
|
1664
|
-
|
|
1665
|
-
function Poppercam:Update(renderDt, desiredCameraCFrame, desiredCameraFocus, cameraController)
|
|
1666
|
-
local rotatedFocus = desiredCameraFocus * (desiredCameraCFrame - desiredCameraCFrame.p)
|
|
1667
|
-
local extrapolation = self.focusExtrapolator:Step(renderDt, rotatedFocus)
|
|
1668
|
-
local zoom = ZoomController.Update(renderDt, rotatedFocus, extrapolation)
|
|
1669
|
-
return rotatedFocus*CFrame.new(0, 0, zoom), desiredCameraFocus
|
|
1670
|
-
end
|
|
1671
|
-
|
|
1672
|
-
-- Base Camera
|
|
1673
|
-
|
|
1674
|
-
local BaseCamera = require(CameraModule:WaitForChild("BaseCamera"))
|
|
1675
|
-
|
|
1676
|
-
function BaseCamera:CalculateNewLookCFrameFromArg(suppliedLookVector, rotateInput)
|
|
1677
|
-
local currLookVector = suppliedLookVector or self:GetCameraLookVector()
|
|
1678
|
-
currLookVector = upCFrame:VectorToObjectSpace(currLookVector)
|
|
1679
|
-
|
|
1680
|
-
local currPitchAngle = math.asin(currLookVector.y)
|
|
1681
|
-
local yTheta = math.clamp(rotateInput.y, -MAX_Y + currPitchAngle, -MIN_Y + currPitchAngle)
|
|
1682
|
-
local constrainedRotateInput = Vector2.new(rotateInput.x, yTheta)
|
|
1683
|
-
local startCFrame = CFrame.new(ZERO3, currLookVector)
|
|
1684
|
-
local newLookCFrame = CFrame.Angles(0, -constrainedRotateInput.x, 0) * startCFrame * CFrame.Angles(-constrainedRotateInput.y,0,0)
|
|
1685
|
-
|
|
1686
|
-
return newLookCFrame
|
|
1687
|
-
end
|
|
1688
|
-
|
|
1689
|
-
function BaseCamera:CalculateNewLookCFrame(suppliedLookVector)
|
|
1690
|
-
return self:CalculateNewLookCFrameFromArg(suppliedLookVector, self.rotateInput)
|
|
1691
|
-
end
|
|
1692
|
-
|
|
1693
|
-
local defaultUpdateMouseBehavior = BaseCamera.UpdateMouseBehavior
|
|
1694
|
-
|
|
1695
|
-
function BaseCamera:UpdateMouseBehavior()
|
|
1696
|
-
defaultUpdateMouseBehavior(self)
|
|
1697
|
-
if UserGameSettings.RotationType == Enum.RotationType.CameraRelative then
|
|
1698
|
-
UserGameSettings.RotationType = Enum.RotationType.MovementRelative
|
|
1699
|
-
end
|
|
1700
|
-
end
|
|
1701
|
-
|
|
1702
|
-
-- Vehicle Camera
|
|
1703
|
-
|
|
1704
|
-
local VehicleCamera = require(CameraModule:WaitForChild("VehicleCamera"))
|
|
1705
|
-
local VehicleCameraCore = require(CameraModule.VehicleCamera:WaitForChild("VehicleCameraCore"))
|
|
1706
|
-
local setTransform = VehicleCameraCore.setTransform
|
|
1707
|
-
|
|
1708
|
-
function VehicleCameraCore:setTransform(transform)
|
|
1709
|
-
transform = upCFrame:ToObjectSpace(transform - transform.p) + transform.p
|
|
1710
|
-
return setTransform(self, transform)
|
|
1711
|
-
end
|
|
1712
|
-
|
|
1713
|
-
-- Camera Module
|
|
1714
|
-
|
|
1715
|
-
local function getRotationBetween(u, v, axis)
|
|
1716
|
-
local dot, uxv = u:Dot(v), u:Cross(v)
|
|
1717
|
-
if dot < -0.99999 then return CFrame.fromAxisAngle(axis, math.pi) end
|
|
1718
|
-
return CFrame.new(0, 0, 0, uxv.x, uxv.y, uxv.z, 1 + dot)
|
|
1719
|
-
end
|
|
1720
|
-
|
|
1721
|
-
local function twistAngle(cf, direction)
|
|
1722
|
-
local axis, theta = cf:ToAxisAngle()
|
|
1723
|
-
local w, v = math.cos(theta/2), math.sin(theta/2)*axis
|
|
1724
|
-
local proj = v:Dot(direction)*direction
|
|
1725
|
-
local twist = CFrame.new(0, 0, 0, proj.x, proj.y, proj.z, w)
|
|
1726
|
-
local nAxis, nTheta = twist:ToAxisAngle()
|
|
1727
|
-
return math.sign(v:Dot(direction))*nTheta
|
|
1728
|
-
end
|
|
1729
|
-
|
|
1730
|
-
local function calculateUpCFrame(self)
|
|
1731
|
-
local newUpVector = self:GetUpVector(upVector)
|
|
1732
|
-
|
|
1733
|
-
local axis = workspace.CurrentCamera.CFrame.RightVector
|
|
1734
|
-
local sphericalArc = getRotationBetween(upVector, newUpVector, axis)
|
|
1735
|
-
local transitionCF = CFrame.new():Lerp(sphericalArc, transitionRate)
|
|
1736
|
-
|
|
1737
|
-
upVector = transitionCF * upVector
|
|
1738
|
-
upCFrame = transitionCF * upCFrame
|
|
1739
|
-
end
|
|
1740
|
-
|
|
1741
|
-
local function calculateSpinCFrame(self)
|
|
1742
|
-
local theta = 0
|
|
1743
|
-
|
|
1744
|
-
if spinPart == prevSpinPart then
|
|
1745
|
-
local rotation = spinPart.CFrame - spinPart.CFrame.p
|
|
1746
|
-
local prevRotation = prevSpinCFrame - prevSpinCFrame.p
|
|
1747
|
-
|
|
1748
|
-
local spinAxis = rotation:VectorToObjectSpace(upVector)
|
|
1749
|
-
theta = twistAngle(prevRotation:ToObjectSpace(rotation), spinAxis)
|
|
1750
|
-
end
|
|
1751
|
-
|
|
1752
|
-
twistCFrame = CFrame.fromEulerAnglesYXZ(0, theta, 0)
|
|
1753
|
-
|
|
1754
|
-
prevSpinPart = spinPart
|
|
1755
|
-
prevSpinCFrame = spinPart.CFrame
|
|
1756
|
-
end
|
|
1757
|
-
|
|
1758
|
-
local Camera = require(CameraModule)
|
|
1759
|
-
local CameraInput = require(CameraModule:WaitForChild("CameraInput"))
|
|
1760
|
-
|
|
1761
|
-
function Camera:GetUpVector(oldUpVector)
|
|
1762
|
-
return oldUpVector
|
|
1763
|
-
end
|
|
1764
|
-
|
|
1765
|
-
function Camera:SetSpinPart(part)
|
|
1766
|
-
spinPart = part
|
|
1767
|
-
end
|
|
1768
|
-
|
|
1769
|
-
function Camera:SetTransitionRate(rate)
|
|
1770
|
-
transitionRate = rate
|
|
1771
|
-
end
|
|
1772
|
-
|
|
1773
|
-
function Camera:GetTransitionRate()
|
|
1774
|
-
return transitionRate
|
|
1775
|
-
end
|
|
1776
|
-
|
|
1777
|
-
function Camera:Update(dt)
|
|
1778
|
-
if self.activeCameraController then
|
|
1779
|
-
self.activeCameraController:UpdateMouseBehavior()
|
|
1780
|
-
|
|
1781
|
-
local newCameraCFrame, newCameraFocus = self.activeCameraController:Update(dt)
|
|
1782
|
-
newCameraFocus = CFrame.new(newCameraFocus.p) -- vehicle camera fix
|
|
1783
|
-
|
|
1784
|
-
-- if not FFlagUserFlagEnableNewVRSystem then
|
|
1785
|
-
--self.activeCameraController:ApplyVRTransform()
|
|
1786
|
-
-- end
|
|
1787
|
-
|
|
1788
|
-
calculateUpCFrame(self, dt)
|
|
1789
|
-
calculateSpinCFrame(self)
|
|
1790
|
-
|
|
1791
|
-
local lockOffset = Vector3.new(0, 0, 0)
|
|
1792
|
-
if self.activeMouseLockController and self.activeMouseLockController:GetIsMouseLocked() then
|
|
1793
|
-
lockOffset = self.activeMouseLockController:GetMouseLockOffset()
|
|
1794
|
-
end
|
|
1795
|
-
|
|
1796
|
-
local offset = newCameraFocus:ToObjectSpace(newCameraCFrame)
|
|
1797
|
-
local camRotation = upCFrame * twistCFrame * offset
|
|
1798
|
-
newCameraFocus = newCameraFocus - newCameraCFrame:VectorToWorldSpace(lockOffset) + camRotation:VectorToWorldSpace(lockOffset)
|
|
1799
|
-
newCameraCFrame = newCameraFocus * camRotation
|
|
1800
|
-
|
|
1801
|
-
if self.activeOcclusionModule then
|
|
1802
|
-
newCameraCFrame, newCameraFocus = self.activeOcclusionModule:Update(dt, newCameraCFrame, newCameraFocus)
|
|
1803
|
-
end
|
|
1804
|
-
|
|
1805
|
-
-- Here is where the new CFrame and Focus are set for this render frame
|
|
1806
|
-
game.Workspace.CurrentCamera.CFrame = newCameraCFrame
|
|
1807
|
-
game.Workspace.CurrentCamera.Focus = newCameraFocus
|
|
1808
|
-
|
|
1809
|
-
-- Update to character local transparency as needed based on camera-to-subject distance
|
|
1810
|
-
if self.activeTransparencyController then
|
|
1811
|
-
self.activeTransparencyController:Update(dt)
|
|
1812
|
-
end
|
|
1813
|
-
|
|
1814
|
-
if CameraInput.getInputEnabled() then
|
|
1815
|
-
CameraInput.resetInputForFrameEnd()
|
|
1816
|
-
end
|
|
1817
|
-
end
|
|
1818
|
-
end
|
|
1819
|
-
|
|
1820
|
-
function Camera:IsFirstPerson()
|
|
1821
|
-
if self.activeCameraController then
|
|
1822
|
-
return self.activeCameraController.inFirstPerson
|
|
1823
|
-
end
|
|
1824
|
-
return false
|
|
1825
|
-
end
|
|
1826
|
-
|
|
1827
|
-
function Camera:IsMouseLocked()
|
|
1828
|
-
if self.activeCameraController then
|
|
1829
|
-
return self.activeCameraController:GetIsMouseLocked()
|
|
1830
|
-
end
|
|
1831
|
-
return false
|
|
1832
|
-
end
|
|
1833
|
-
|
|
1834
|
-
function Camera:IsToggleMode()
|
|
1835
|
-
if self.activeCameraController then
|
|
1836
|
-
return self.activeCameraController.isCameraToggle
|
|
1837
|
-
end
|
|
1838
|
-
return false
|
|
1839
|
-
end
|
|
1840
|
-
|
|
1841
|
-
function Camera:IsCamRelative()
|
|
1842
|
-
return self:IsMouseLocked() or self:IsFirstPerson()
|
|
1843
|
-
--return self:IsToggleMode(), self:IsMouseLocked(), self:IsFirstPerson()
|
|
1844
|
-
end
|
|
1845
|
-
|
|
1846
|
-
--
|
|
1847
|
-
|
|
1848
|
-
require(PlayerModule)</string>
|
|
1849
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
1850
|
-
<BinaryString name="Tags"></BinaryString>
|
|
1851
|
-
</Properties>
|
|
1852
|
-
<Item class="ModuleScript" referent="11">
|
|
1853
|
-
<Properties>
|
|
1854
|
-
<string name="Name">CameraInjector</string>
|
|
1855
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1856
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
1857
|
-
<Content name="LinkedSource">
|
|
1858
|
-
<null>
|
|
1859
|
-
</null>
|
|
1860
|
-
</Content>
|
|
1861
|
-
<string name="Source"><![CDATA[-- Injects into the CameraModule to override for public API access
|
|
1862
|
-
-- EgoMoose
|
|
1863
|
-
|
|
1864
|
-
local FakeUserSettingsFunc = require(script.Parent:WaitForChild("FakeUserSettings"))
|
|
1865
|
-
|
|
1866
|
-
-- Camera Injection
|
|
1867
|
-
|
|
1868
|
-
local PlayerModule = script.Parent.Parent:WaitForChild("PlayerModule")
|
|
1869
|
-
local CameraModule = PlayerModule:WaitForChild("CameraModule")
|
|
1870
|
-
local TransparencyController = require(CameraModule:WaitForChild("TransparencyController"))
|
|
1871
|
-
|
|
1872
|
-
local result = nil
|
|
1873
|
-
local copy = TransparencyController.Enable
|
|
1874
|
-
local bind = Instance.new("BindableEvent")
|
|
1875
|
-
|
|
1876
|
-
local CameraModuleSelf = nil
|
|
1877
|
-
local CameraModuleMeta = nil
|
|
1878
|
-
|
|
1879
|
-
local metasetmetatable = function(newTable:{}, newMeta:{})
|
|
1880
|
-
local env = getfenv(2)
|
|
1881
|
-
if env.script==CameraModule then
|
|
1882
|
-
CameraModuleSelf = newTable
|
|
1883
|
-
CameraModuleMeta = newMeta
|
|
1884
|
-
end
|
|
1885
|
-
return setmetatable(newTable, newMeta)
|
|
1886
|
-
end
|
|
1887
|
-
|
|
1888
|
-
local phaseTwoEnable = function(self, ...)
|
|
1889
|
-
local env = getfenv(3)
|
|
1890
|
-
env.setmetatable = nil
|
|
1891
|
-
setfenv(3, env)
|
|
1892
|
-
|
|
1893
|
-
TransparencyController.Enable = copy
|
|
1894
|
-
return copy(self, ...)
|
|
1895
|
-
end
|
|
1896
|
-
|
|
1897
|
-
TransparencyController.Enable = function(self, ...)
|
|
1898
|
-
copy(self, ...)
|
|
1899
|
-
|
|
1900
|
-
local env = getfenv(3)
|
|
1901
|
-
env.UserSettings = FakeUserSettingsFunc
|
|
1902
|
-
env.setmetatable = metasetmetatable
|
|
1903
|
-
local f = setfenv(3, env)
|
|
1904
|
-
|
|
1905
|
-
TransparencyController.Enable = phaseTwoEnable
|
|
1906
|
-
|
|
1907
|
-
result = f()
|
|
1908
|
-
if result.ActivateCameraController==nil
|
|
1909
|
-
and typeof(CameraModuleSelf)=="table"
|
|
1910
|
-
and typeof(CameraModuleSelf.ActivateCameraController)=="function" then
|
|
1911
|
-
result = CameraModuleSelf
|
|
1912
|
-
end
|
|
1913
|
-
bind.Event:Wait() -- infinite wait so no more connections can be made
|
|
1914
|
-
end
|
|
1915
|
-
|
|
1916
|
-
coroutine.wrap(function()
|
|
1917
|
-
require(CameraModule)
|
|
1918
|
-
end)()
|
|
1919
|
-
|
|
1920
|
-
-- Place children under injection
|
|
1921
|
-
|
|
1922
|
-
for _, child in pairs(CameraModule:GetChildren()) do
|
|
1923
|
-
child.Parent = script
|
|
1924
|
-
end
|
|
1925
|
-
|
|
1926
|
-
CameraModule.Name = "_CameraModule"
|
|
1927
|
-
script.Name = "CameraModule"
|
|
1928
|
-
script.Parent = PlayerModule
|
|
1929
|
-
|
|
1930
|
-
--
|
|
1931
|
-
|
|
1932
|
-
return result
|
|
1933
|
-
]]></string>
|
|
1934
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
1935
|
-
<BinaryString name="Tags"></BinaryString>
|
|
1936
|
-
</Properties>
|
|
1937
|
-
</Item>
|
|
1938
|
-
<Item class="ModuleScript" referent="12">
|
|
1939
|
-
<Properties>
|
|
1940
|
-
<string name="Name">FakeUserSettings</string>
|
|
1941
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1942
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
1943
|
-
<Content name="LinkedSource">
|
|
1944
|
-
<null>
|
|
1945
|
-
</null>
|
|
1946
|
-
</Content>
|
|
1577
|
+
end</string>
|
|
1578
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
1579
|
+
<BinaryString name="Tags"></BinaryString>
|
|
1580
|
+
</Properties>
|
|
1581
|
+
</Item>
|
|
1582
|
+
</Item>
|
|
1583
|
+
<Item class="LocalScript" referent="10">
|
|
1584
|
+
<Properties>
|
|
1585
|
+
<string name="Name">PlayerScriptsLoader</string>
|
|
1586
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1587
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
1588
|
+
<bool name="Disabled">false</bool>
|
|
1589
|
+
<Content name="LinkedSource">
|
|
1590
|
+
<null>
|
|
1591
|
+
</null>
|
|
1592
|
+
</Content>
|
|
1593
|
+
<token name="RunContext">0</token>
|
|
1594
|
+
<string name="Source">--[[
|
|
1595
|
+
PlayerScriptsLoader - This script requires and instantiates the PlayerModule singleton
|
|
1596
|
+
|
|
1597
|
+
2018 PlayerScripts Update - AllYourBlox
|
|
1598
|
+
2020 CameraModule Public Access Override & modifications - EgoMoose
|
|
1599
|
+
--]]
|
|
1600
|
+
|
|
1601
|
+
local MIN_Y = math.rad(-80)
|
|
1602
|
+
local MAX_Y = math.rad(80)
|
|
1603
|
+
local ZERO3 = Vector3.new(0, 0, 0)
|
|
1604
|
+
|
|
1605
|
+
local PlayerModule = script.Parent:WaitForChild("PlayerModule")
|
|
1606
|
+
local CameraInjector = script:WaitForChild("CameraInjector")
|
|
1607
|
+
|
|
1608
|
+
require(CameraInjector)
|
|
1609
|
+
|
|
1610
|
+
-- Control Modifications
|
|
1611
|
+
|
|
1612
|
+
local Control = require(PlayerModule:WaitForChild("ControlModule"))
|
|
1613
|
+
local TouchJump = require(PlayerModule.ControlModule:WaitForChild("TouchJump"))
|
|
1614
|
+
|
|
1615
|
+
function Control:IsJumping()
|
|
1616
|
+
if self.activeController then
|
|
1617
|
+
return self.activeController:GetIsJumping()
|
|
1618
|
+
or (self.touchJumpController and self.touchJumpController:GetIsJumping())
|
|
1619
|
+
end
|
|
1620
|
+
return false
|
|
1621
|
+
end
|
|
1622
|
+
|
|
1623
|
+
local oldEnabled = TouchJump.UpdateEnabled
|
|
1624
|
+
|
|
1625
|
+
function TouchJump:UpdateEnabled()
|
|
1626
|
+
self.jumpStateEnabled = true
|
|
1627
|
+
oldEnabled(self)
|
|
1628
|
+
end
|
|
1629
|
+
|
|
1630
|
+
-- Camera Modifications
|
|
1631
|
+
|
|
1632
|
+
local CameraModule = PlayerModule:WaitForChild("CameraModule")
|
|
1633
|
+
|
|
1634
|
+
local UserSettings = require(script:WaitForChild("FakeUserSettings"))
|
|
1635
|
+
local UserGameSettings = UserSettings():GetService("UserGameSettings")
|
|
1636
|
+
|
|
1637
|
+
local FFlagUserFlagEnableNewVRSystem = UserSettings():SafeIsUserFeatureEnabled("UserFlagEnableNewVRSystem")
|
|
1638
|
+
|
|
1639
|
+
-- Camera variables
|
|
1640
|
+
|
|
1641
|
+
local transitionRate = 0.15
|
|
1642
|
+
local upVector = Vector3.new(0, 1, 0)
|
|
1643
|
+
local upCFrame = CFrame.new()
|
|
1644
|
+
|
|
1645
|
+
local spinPart = workspace.Terrain
|
|
1646
|
+
local prevSpinPart = spinPart
|
|
1647
|
+
local prevSpinCFrame = spinPart.CFrame
|
|
1648
|
+
local twistCFrame = CFrame.new()
|
|
1649
|
+
|
|
1650
|
+
-- Camera Utilities
|
|
1651
|
+
|
|
1652
|
+
local Utils = require(CameraModule:WaitForChild("CameraUtils"))
|
|
1653
|
+
|
|
1654
|
+
function Utils.GetAngleBetweenXZVectors(v1, v2)
|
|
1655
|
+
v1 = upCFrame:VectorToObjectSpace(v1)
|
|
1656
|
+
v2 = upCFrame:VectorToObjectSpace(v2)
|
|
1657
|
+
return math.atan2(v2.X*v1.Z-v2.Z*v1.X, v2.X*v1.X+v2.Z*v1.Z)
|
|
1658
|
+
end
|
|
1659
|
+
|
|
1660
|
+
-- Popper Camera
|
|
1661
|
+
|
|
1662
|
+
local Poppercam = require(CameraModule:WaitForChild("Poppercam"))
|
|
1663
|
+
local ZoomController = require(CameraModule:WaitForChild("ZoomController"))
|
|
1664
|
+
|
|
1665
|
+
function Poppercam:Update(renderDt, desiredCameraCFrame, desiredCameraFocus, cameraController)
|
|
1666
|
+
local rotatedFocus = desiredCameraFocus * (desiredCameraCFrame - desiredCameraCFrame.p)
|
|
1667
|
+
local extrapolation = self.focusExtrapolator:Step(renderDt, rotatedFocus)
|
|
1668
|
+
local zoom = ZoomController.Update(renderDt, rotatedFocus, extrapolation)
|
|
1669
|
+
return rotatedFocus*CFrame.new(0, 0, zoom), desiredCameraFocus
|
|
1670
|
+
end
|
|
1671
|
+
|
|
1672
|
+
-- Base Camera
|
|
1673
|
+
|
|
1674
|
+
local BaseCamera = require(CameraModule:WaitForChild("BaseCamera"))
|
|
1675
|
+
|
|
1676
|
+
function BaseCamera:CalculateNewLookCFrameFromArg(suppliedLookVector, rotateInput)
|
|
1677
|
+
local currLookVector = suppliedLookVector or self:GetCameraLookVector()
|
|
1678
|
+
currLookVector = upCFrame:VectorToObjectSpace(currLookVector)
|
|
1679
|
+
|
|
1680
|
+
local currPitchAngle = math.asin(currLookVector.y)
|
|
1681
|
+
local yTheta = math.clamp(rotateInput.y, -MAX_Y + currPitchAngle, -MIN_Y + currPitchAngle)
|
|
1682
|
+
local constrainedRotateInput = Vector2.new(rotateInput.x, yTheta)
|
|
1683
|
+
local startCFrame = CFrame.new(ZERO3, currLookVector)
|
|
1684
|
+
local newLookCFrame = CFrame.Angles(0, -constrainedRotateInput.x, 0) * startCFrame * CFrame.Angles(-constrainedRotateInput.y,0,0)
|
|
1685
|
+
|
|
1686
|
+
return newLookCFrame
|
|
1687
|
+
end
|
|
1688
|
+
|
|
1689
|
+
function BaseCamera:CalculateNewLookCFrame(suppliedLookVector)
|
|
1690
|
+
return self:CalculateNewLookCFrameFromArg(suppliedLookVector, self.rotateInput)
|
|
1691
|
+
end
|
|
1692
|
+
|
|
1693
|
+
local defaultUpdateMouseBehavior = BaseCamera.UpdateMouseBehavior
|
|
1694
|
+
|
|
1695
|
+
function BaseCamera:UpdateMouseBehavior()
|
|
1696
|
+
defaultUpdateMouseBehavior(self)
|
|
1697
|
+
if UserGameSettings.RotationType == Enum.RotationType.CameraRelative then
|
|
1698
|
+
UserGameSettings.RotationType = Enum.RotationType.MovementRelative
|
|
1699
|
+
end
|
|
1700
|
+
end
|
|
1701
|
+
|
|
1702
|
+
-- Vehicle Camera
|
|
1703
|
+
|
|
1704
|
+
local VehicleCamera = require(CameraModule:WaitForChild("VehicleCamera"))
|
|
1705
|
+
local VehicleCameraCore = require(CameraModule.VehicleCamera:WaitForChild("VehicleCameraCore"))
|
|
1706
|
+
local setTransform = VehicleCameraCore.setTransform
|
|
1707
|
+
|
|
1708
|
+
function VehicleCameraCore:setTransform(transform)
|
|
1709
|
+
transform = upCFrame:ToObjectSpace(transform - transform.p) + transform.p
|
|
1710
|
+
return setTransform(self, transform)
|
|
1711
|
+
end
|
|
1712
|
+
|
|
1713
|
+
-- Camera Module
|
|
1714
|
+
|
|
1715
|
+
local function getRotationBetween(u, v, axis)
|
|
1716
|
+
local dot, uxv = u:Dot(v), u:Cross(v)
|
|
1717
|
+
if dot < -0.99999 then return CFrame.fromAxisAngle(axis, math.pi) end
|
|
1718
|
+
return CFrame.new(0, 0, 0, uxv.x, uxv.y, uxv.z, 1 + dot)
|
|
1719
|
+
end
|
|
1720
|
+
|
|
1721
|
+
local function twistAngle(cf, direction)
|
|
1722
|
+
local axis, theta = cf:ToAxisAngle()
|
|
1723
|
+
local w, v = math.cos(theta/2), math.sin(theta/2)*axis
|
|
1724
|
+
local proj = v:Dot(direction)*direction
|
|
1725
|
+
local twist = CFrame.new(0, 0, 0, proj.x, proj.y, proj.z, w)
|
|
1726
|
+
local nAxis, nTheta = twist:ToAxisAngle()
|
|
1727
|
+
return math.sign(v:Dot(direction))*nTheta
|
|
1728
|
+
end
|
|
1729
|
+
|
|
1730
|
+
local function calculateUpCFrame(self)
|
|
1731
|
+
local newUpVector = self:GetUpVector(upVector)
|
|
1732
|
+
|
|
1733
|
+
local axis = workspace.CurrentCamera.CFrame.RightVector
|
|
1734
|
+
local sphericalArc = getRotationBetween(upVector, newUpVector, axis)
|
|
1735
|
+
local transitionCF = CFrame.new():Lerp(sphericalArc, transitionRate)
|
|
1736
|
+
|
|
1737
|
+
upVector = transitionCF * upVector
|
|
1738
|
+
upCFrame = transitionCF * upCFrame
|
|
1739
|
+
end
|
|
1740
|
+
|
|
1741
|
+
local function calculateSpinCFrame(self)
|
|
1742
|
+
local theta = 0
|
|
1743
|
+
|
|
1744
|
+
if spinPart == prevSpinPart then
|
|
1745
|
+
local rotation = spinPart.CFrame - spinPart.CFrame.p
|
|
1746
|
+
local prevRotation = prevSpinCFrame - prevSpinCFrame.p
|
|
1747
|
+
|
|
1748
|
+
local spinAxis = rotation:VectorToObjectSpace(upVector)
|
|
1749
|
+
theta = twistAngle(prevRotation:ToObjectSpace(rotation), spinAxis)
|
|
1750
|
+
end
|
|
1751
|
+
|
|
1752
|
+
twistCFrame = CFrame.fromEulerAnglesYXZ(0, theta, 0)
|
|
1753
|
+
|
|
1754
|
+
prevSpinPart = spinPart
|
|
1755
|
+
prevSpinCFrame = spinPart.CFrame
|
|
1756
|
+
end
|
|
1757
|
+
|
|
1758
|
+
local Camera = require(CameraModule)
|
|
1759
|
+
local CameraInput = require(CameraModule:WaitForChild("CameraInput"))
|
|
1760
|
+
|
|
1761
|
+
function Camera:GetUpVector(oldUpVector)
|
|
1762
|
+
return oldUpVector
|
|
1763
|
+
end
|
|
1764
|
+
|
|
1765
|
+
function Camera:SetSpinPart(part)
|
|
1766
|
+
spinPart = part
|
|
1767
|
+
end
|
|
1768
|
+
|
|
1769
|
+
function Camera:SetTransitionRate(rate)
|
|
1770
|
+
transitionRate = rate
|
|
1771
|
+
end
|
|
1772
|
+
|
|
1773
|
+
function Camera:GetTransitionRate()
|
|
1774
|
+
return transitionRate
|
|
1775
|
+
end
|
|
1776
|
+
|
|
1777
|
+
function Camera:Update(dt)
|
|
1778
|
+
if self.activeCameraController then
|
|
1779
|
+
self.activeCameraController:UpdateMouseBehavior()
|
|
1780
|
+
|
|
1781
|
+
local newCameraCFrame, newCameraFocus = self.activeCameraController:Update(dt)
|
|
1782
|
+
newCameraFocus = CFrame.new(newCameraFocus.p) -- vehicle camera fix
|
|
1783
|
+
|
|
1784
|
+
-- if not FFlagUserFlagEnableNewVRSystem then
|
|
1785
|
+
--self.activeCameraController:ApplyVRTransform()
|
|
1786
|
+
-- end
|
|
1787
|
+
|
|
1788
|
+
calculateUpCFrame(self, dt)
|
|
1789
|
+
calculateSpinCFrame(self)
|
|
1790
|
+
|
|
1791
|
+
local lockOffset = Vector3.new(0, 0, 0)
|
|
1792
|
+
if self.activeMouseLockController and self.activeMouseLockController:GetIsMouseLocked() then
|
|
1793
|
+
lockOffset = self.activeMouseLockController:GetMouseLockOffset()
|
|
1794
|
+
end
|
|
1795
|
+
|
|
1796
|
+
local offset = newCameraFocus:ToObjectSpace(newCameraCFrame)
|
|
1797
|
+
local camRotation = upCFrame * twistCFrame * offset
|
|
1798
|
+
newCameraFocus = newCameraFocus - newCameraCFrame:VectorToWorldSpace(lockOffset) + camRotation:VectorToWorldSpace(lockOffset)
|
|
1799
|
+
newCameraCFrame = newCameraFocus * camRotation
|
|
1800
|
+
|
|
1801
|
+
if self.activeOcclusionModule then
|
|
1802
|
+
newCameraCFrame, newCameraFocus = self.activeOcclusionModule:Update(dt, newCameraCFrame, newCameraFocus)
|
|
1803
|
+
end
|
|
1804
|
+
|
|
1805
|
+
-- Here is where the new CFrame and Focus are set for this render frame
|
|
1806
|
+
game.Workspace.CurrentCamera.CFrame = newCameraCFrame
|
|
1807
|
+
game.Workspace.CurrentCamera.Focus = newCameraFocus
|
|
1808
|
+
|
|
1809
|
+
-- Update to character local transparency as needed based on camera-to-subject distance
|
|
1810
|
+
if self.activeTransparencyController then
|
|
1811
|
+
self.activeTransparencyController:Update(dt)
|
|
1812
|
+
end
|
|
1813
|
+
|
|
1814
|
+
if CameraInput.getInputEnabled() then
|
|
1815
|
+
CameraInput.resetInputForFrameEnd()
|
|
1816
|
+
end
|
|
1817
|
+
end
|
|
1818
|
+
end
|
|
1819
|
+
|
|
1820
|
+
function Camera:IsFirstPerson()
|
|
1821
|
+
if self.activeCameraController then
|
|
1822
|
+
return self.activeCameraController.inFirstPerson
|
|
1823
|
+
end
|
|
1824
|
+
return false
|
|
1825
|
+
end
|
|
1826
|
+
|
|
1827
|
+
function Camera:IsMouseLocked()
|
|
1828
|
+
if self.activeCameraController then
|
|
1829
|
+
return self.activeCameraController:GetIsMouseLocked()
|
|
1830
|
+
end
|
|
1831
|
+
return false
|
|
1832
|
+
end
|
|
1833
|
+
|
|
1834
|
+
function Camera:IsToggleMode()
|
|
1835
|
+
if self.activeCameraController then
|
|
1836
|
+
return self.activeCameraController.isCameraToggle
|
|
1837
|
+
end
|
|
1838
|
+
return false
|
|
1839
|
+
end
|
|
1840
|
+
|
|
1841
|
+
function Camera:IsCamRelative()
|
|
1842
|
+
return self:IsMouseLocked() or self:IsFirstPerson()
|
|
1843
|
+
--return self:IsToggleMode(), self:IsMouseLocked(), self:IsFirstPerson()
|
|
1844
|
+
end
|
|
1845
|
+
|
|
1846
|
+
--
|
|
1847
|
+
|
|
1848
|
+
require(PlayerModule)</string>
|
|
1849
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
1850
|
+
<BinaryString name="Tags"></BinaryString>
|
|
1851
|
+
</Properties>
|
|
1852
|
+
<Item class="ModuleScript" referent="11">
|
|
1853
|
+
<Properties>
|
|
1854
|
+
<string name="Name">CameraInjector</string>
|
|
1855
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1856
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
1857
|
+
<Content name="LinkedSource">
|
|
1858
|
+
<null>
|
|
1859
|
+
</null>
|
|
1860
|
+
</Content>
|
|
1861
|
+
<string name="Source"><![CDATA[-- Injects into the CameraModule to override for public API access
|
|
1862
|
+
-- EgoMoose
|
|
1863
|
+
|
|
1864
|
+
local FakeUserSettingsFunc = require(script.Parent:WaitForChild("FakeUserSettings"))
|
|
1865
|
+
|
|
1866
|
+
-- Camera Injection
|
|
1867
|
+
|
|
1868
|
+
local PlayerModule = script.Parent.Parent:WaitForChild("PlayerModule")
|
|
1869
|
+
local CameraModule = PlayerModule:WaitForChild("CameraModule")
|
|
1870
|
+
local TransparencyController = require(CameraModule:WaitForChild("TransparencyController"))
|
|
1871
|
+
|
|
1872
|
+
local result = nil
|
|
1873
|
+
local copy = TransparencyController.Enable
|
|
1874
|
+
local bind = Instance.new("BindableEvent")
|
|
1875
|
+
|
|
1876
|
+
local CameraModuleSelf = nil
|
|
1877
|
+
local CameraModuleMeta = nil
|
|
1878
|
+
|
|
1879
|
+
local metasetmetatable = function(newTable:{}, newMeta:{})
|
|
1880
|
+
local env = getfenv(2)
|
|
1881
|
+
if env.script==CameraModule then
|
|
1882
|
+
CameraModuleSelf = newTable
|
|
1883
|
+
CameraModuleMeta = newMeta
|
|
1884
|
+
end
|
|
1885
|
+
return setmetatable(newTable, newMeta)
|
|
1886
|
+
end
|
|
1887
|
+
|
|
1888
|
+
local phaseTwoEnable = function(self, ...)
|
|
1889
|
+
local env = getfenv(3)
|
|
1890
|
+
env.setmetatable = nil
|
|
1891
|
+
setfenv(3, env)
|
|
1892
|
+
|
|
1893
|
+
TransparencyController.Enable = copy
|
|
1894
|
+
return copy(self, ...)
|
|
1895
|
+
end
|
|
1896
|
+
|
|
1897
|
+
TransparencyController.Enable = function(self, ...)
|
|
1898
|
+
copy(self, ...)
|
|
1899
|
+
|
|
1900
|
+
local env = getfenv(3)
|
|
1901
|
+
env.UserSettings = FakeUserSettingsFunc
|
|
1902
|
+
env.setmetatable = metasetmetatable
|
|
1903
|
+
local f = setfenv(3, env)
|
|
1904
|
+
|
|
1905
|
+
TransparencyController.Enable = phaseTwoEnable
|
|
1906
|
+
|
|
1907
|
+
result = f()
|
|
1908
|
+
if result.ActivateCameraController==nil
|
|
1909
|
+
and typeof(CameraModuleSelf)=="table"
|
|
1910
|
+
and typeof(CameraModuleSelf.ActivateCameraController)=="function" then
|
|
1911
|
+
result = CameraModuleSelf
|
|
1912
|
+
end
|
|
1913
|
+
bind.Event:Wait() -- infinite wait so no more connections can be made
|
|
1914
|
+
end
|
|
1915
|
+
|
|
1916
|
+
coroutine.wrap(function()
|
|
1917
|
+
require(CameraModule)
|
|
1918
|
+
end)()
|
|
1919
|
+
|
|
1920
|
+
-- Place children under injection
|
|
1921
|
+
|
|
1922
|
+
for _, child in pairs(CameraModule:GetChildren()) do
|
|
1923
|
+
child.Parent = script
|
|
1924
|
+
end
|
|
1925
|
+
|
|
1926
|
+
CameraModule.Name = "_CameraModule"
|
|
1927
|
+
script.Name = "CameraModule"
|
|
1928
|
+
script.Parent = PlayerModule
|
|
1929
|
+
|
|
1930
|
+
--
|
|
1931
|
+
|
|
1932
|
+
return result
|
|
1933
|
+
]]></string>
|
|
1934
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
1935
|
+
<BinaryString name="Tags"></BinaryString>
|
|
1936
|
+
</Properties>
|
|
1937
|
+
</Item>
|
|
1938
|
+
<Item class="ModuleScript" referent="12">
|
|
1939
|
+
<Properties>
|
|
1940
|
+
<string name="Name">FakeUserSettings</string>
|
|
1941
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1942
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
1943
|
+
<Content name="LinkedSource">
|
|
1944
|
+
<null>
|
|
1945
|
+
</null>
|
|
1946
|
+
</Content>
|
|
1947
1947
|
<string name="Source">local FFLAG_OVERRIDES = {
|
|
1948
1948
|
["UserRemoveTheCameraApi"] = false
|
|
1949
1949
|
}
|
|
@@ -1972,23 +1972,23 @@ local function FakeUserSettingsFunc()
|
|
|
1972
1972
|
return FakeUserSettings
|
|
1973
1973
|
end
|
|
1974
1974
|
|
|
1975
|
-
return FakeUserSettingsFunc</string>
|
|
1976
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
1977
|
-
<BinaryString name="Tags"></BinaryString>
|
|
1978
|
-
</Properties>
|
|
1979
|
-
</Item>
|
|
1980
|
-
</Item>
|
|
1981
|
-
<Item class="LocalScript" referent="13">
|
|
1982
|
-
<Properties>
|
|
1983
|
-
<string name="Name">RbxCharacterSounds</string>
|
|
1984
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1985
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
1986
|
-
<bool name="Disabled">false</bool>
|
|
1987
|
-
<Content name="LinkedSource">
|
|
1988
|
-
<null>
|
|
1989
|
-
</null>
|
|
1990
|
-
</Content>
|
|
1991
|
-
<token name="RunContext">0</token>
|
|
1975
|
+
return FakeUserSettingsFunc</string>
|
|
1976
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
1977
|
+
<BinaryString name="Tags"></BinaryString>
|
|
1978
|
+
</Properties>
|
|
1979
|
+
</Item>
|
|
1980
|
+
</Item>
|
|
1981
|
+
<Item class="LocalScript" referent="13">
|
|
1982
|
+
<Properties>
|
|
1983
|
+
<string name="Name">RbxCharacterSounds</string>
|
|
1984
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
1985
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
1986
|
+
<bool name="Disabled">false</bool>
|
|
1987
|
+
<Content name="LinkedSource">
|
|
1988
|
+
<null>
|
|
1989
|
+
</null>
|
|
1990
|
+
</Content>
|
|
1991
|
+
<token name="RunContext">0</token>
|
|
1992
1992
|
<string name="Source"><![CDATA[-- Roblox character sound script
|
|
1993
1993
|
|
|
1994
1994
|
local Players = game:GetService("Players")
|
|
@@ -2310,19 +2310,19 @@ Players.PlayerAdded:Connect(playerAdded)
|
|
|
2310
2310
|
for _, player in ipairs(Players:GetPlayers()) do
|
|
2311
2311
|
playerAdded(player)
|
|
2312
2312
|
end
|
|
2313
|
-
]]></string>
|
|
2314
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
2315
|
-
<BinaryString name="Tags"></BinaryString>
|
|
2316
|
-
</Properties>
|
|
2317
|
-
<Item class="ModuleScript" referent="14">
|
|
2318
|
-
<Properties>
|
|
2319
|
-
<string name="Name">AnimationState</string>
|
|
2320
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2321
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
2322
|
-
<Content name="LinkedSource">
|
|
2323
|
-
<null>
|
|
2324
|
-
</null>
|
|
2325
|
-
</Content>
|
|
2313
|
+
]]></string>
|
|
2314
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
2315
|
+
<BinaryString name="Tags"></BinaryString>
|
|
2316
|
+
</Properties>
|
|
2317
|
+
<Item class="ModuleScript" referent="14">
|
|
2318
|
+
<Properties>
|
|
2319
|
+
<string name="Name">AnimationState</string>
|
|
2320
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2321
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
2322
|
+
<Content name="LinkedSource">
|
|
2323
|
+
<null>
|
|
2324
|
+
</null>
|
|
2325
|
+
</Content>
|
|
2326
2326
|
<string name="Source">local STATE_MAP = {
|
|
2327
2327
|
["climb"] = Enum.HumanoidStateType.Climbing,
|
|
2328
2328
|
["fall"] = Enum.HumanoidStateType.Freefall,
|
|
@@ -2351,22 +2351,22 @@ return function(animator, callback)
|
|
|
2351
2351
|
prevState = state
|
|
2352
2352
|
end
|
|
2353
2353
|
end)
|
|
2354
|
-
end</string>
|
|
2355
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
2356
|
-
<BinaryString name="Tags"></BinaryString>
|
|
2357
|
-
</Properties>
|
|
2358
|
-
</Item>
|
|
2359
|
-
</Item>
|
|
2360
|
-
</Item>
|
|
2361
|
-
<Item class="ModuleScript" referent="15">
|
|
2362
|
-
<Properties>
|
|
2363
|
-
<string name="Name">GravityController</string>
|
|
2364
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2365
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
2366
|
-
<Content name="LinkedSource">
|
|
2367
|
-
<null>
|
|
2368
|
-
</null>
|
|
2369
|
-
</Content>
|
|
2354
|
+
end</string>
|
|
2355
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
2356
|
+
<BinaryString name="Tags"></BinaryString>
|
|
2357
|
+
</Properties>
|
|
2358
|
+
</Item>
|
|
2359
|
+
</Item>
|
|
2360
|
+
</Item>
|
|
2361
|
+
<Item class="ModuleScript" referent="15">
|
|
2362
|
+
<Properties>
|
|
2363
|
+
<string name="Name">GravityController</string>
|
|
2364
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2365
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
2366
|
+
<Content name="LinkedSource">
|
|
2367
|
+
<null>
|
|
2368
|
+
</null>
|
|
2369
|
+
</Content>
|
|
2370
2370
|
<string name="Source">local RunService = game:GetService("RunService")
|
|
2371
2371
|
|
|
2372
2372
|
local Utility = script:WaitForChild("Utility")
|
|
@@ -2379,11 +2379,29 @@ local Control = require(CharacterModules:WaitForChild("Control"))
|
|
|
2379
2379
|
local Collider = require(script:WaitForChild("Collider"))
|
|
2380
2380
|
local StateTracker = require(script:WaitForChild("StateTracker"))
|
|
2381
2381
|
|
|
2382
|
-
-- CONSTANTS
|
|
2382
|
+
-- CONSTANTS (can be configured via SetConstants)
|
|
2383
2383
|
|
|
2384
2384
|
local TRANSITION = 0.15
|
|
2385
2385
|
local WALK_FORCE = 200 / 3
|
|
2386
2386
|
local JUMP_MODIFIER = 1.2
|
|
2387
|
+
local USE_BODY_POSITION_LOCK = false -- Use BodyPosition to prevent sliding on aligned surfaces
|
|
2388
|
+
|
|
2389
|
+
-- Module-level configuration function
|
|
2390
|
+
local function SetConstants(config)
|
|
2391
|
+
if config.Transition ~= nil then
|
|
2392
|
+
TRANSITION = config.Transition
|
|
2393
|
+
end
|
|
2394
|
+
if config.WalkForce ~= nil then
|
|
2395
|
+
WALK_FORCE = config.WalkForce
|
|
2396
|
+
end
|
|
2397
|
+
if config.JumpModifier ~= nil then
|
|
2398
|
+
JUMP_MODIFIER = config.JumpModifier
|
|
2399
|
+
end
|
|
2400
|
+
if config.UseBodyPositionLock ~= nil then
|
|
2401
|
+
USE_BODY_POSITION_LOCK = config.UseBodyPositionLock
|
|
2402
|
+
end
|
|
2403
|
+
-- print("Set constants", config, WALK_FORCE, USE_BODY_POSITION_LOCK)
|
|
2404
|
+
end
|
|
2387
2405
|
|
|
2388
2406
|
local ZERO3 = Vector3.new(0, 0, 0)
|
|
2389
2407
|
local UNIT_Y = Vector3.new(0, 1, 0)
|
|
@@ -2443,6 +2461,10 @@ end
|
|
|
2443
2461
|
|
|
2444
2462
|
local function onJumpRequest(self)
|
|
2445
2463
|
if not self.StateTracker.Jumped and self._collider:IsGrounded(true) then
|
|
2464
|
+
-- Release horizontal lock before jumping
|
|
2465
|
+
if USE_BODY_POSITION_LOCK then
|
|
2466
|
+
self._collider:SetHorizontalLock(false)
|
|
2467
|
+
end
|
|
2446
2468
|
local vel = self.HRP.Velocity
|
|
2447
2469
|
self.HRP.Velocity = vel + self._gravityUp*self.Humanoid.JumpPower*JUMP_MODIFIER
|
|
2448
2470
|
self.StateTracker:RequestJump()
|
|
@@ -2473,6 +2495,8 @@ local function onGravityStep(self, dt)
|
|
|
2473
2495
|
|
|
2474
2496
|
self._gravityUp = lerpedArc * oldGravity
|
|
2475
2497
|
|
|
2498
|
+
self._collider:CorrectPositionIfStuck(self._gravityUp)
|
|
2499
|
+
|
|
2476
2500
|
-- get world move vector
|
|
2477
2501
|
local fDot = camCF.ZVector:Dot(newGravity)
|
|
2478
2502
|
local cForward = math.abs(fDot) > 0.5 and math.sign(fDot)*camCF.YVector or -camCF.ZVector
|
|
@@ -2529,6 +2553,29 @@ local function onGravityStep(self, dt)
|
|
|
2529
2553
|
|
|
2530
2554
|
local charRotation = newCharRotation * newCharCF
|
|
2531
2555
|
|
|
2556
|
+
-- Check if we should lock horizontal position to prevent sliding
|
|
2557
|
+
if USE_BODY_POSITION_LOCK then
|
|
2558
|
+
local isGrounded = self._collider:IsGrounded(false)
|
|
2559
|
+
local surfaceNormal = isGrounded and self._collider:GetSurfaceNormal()
|
|
2560
|
+
local isJumping = self.StateTracker.Jumped or self.StateTracker.State == Enum.HumanoidStateType.Jumping
|
|
2561
|
+
|
|
2562
|
+
-- Don't lock when jumping or not on aligned surface with no input
|
|
2563
|
+
if isGrounded and not isInputMoving and not isJumping and surfaceNormal then
|
|
2564
|
+
local gravityAlignment = math.abs(surfaceNormal:Dot(self._gravityUp))
|
|
2565
|
+
if gravityAlignment > 0.99 then
|
|
2566
|
+
-- Lock horizontal position to prevent sliding
|
|
2567
|
+
self._collider:SetHorizontalLock(true, self.HRP.Position, surfaceNormal)
|
|
2568
|
+
else
|
|
2569
|
+
self._collider:SetHorizontalLock(false)
|
|
2570
|
+
end
|
|
2571
|
+
else
|
|
2572
|
+
self._collider:SetHorizontalLock(false)
|
|
2573
|
+
end
|
|
2574
|
+
else
|
|
2575
|
+
-- Ensure lock is disabled if not using this approach
|
|
2576
|
+
self._collider:SetHorizontalLock(false)
|
|
2577
|
+
end
|
|
2578
|
+
|
|
2532
2579
|
self.StateTracker:Update(self._gravityUp, self._collider:IsGrounded(false), isInputMoving)
|
|
2533
2580
|
self._collider:Update(walkForce + gForce, charRotation)
|
|
2534
2581
|
end
|
|
@@ -2571,6 +2618,10 @@ end
|
|
|
2571
2618
|
|
|
2572
2619
|
-- Public Methods
|
|
2573
2620
|
|
|
2621
|
+
function GravityControllerClass.SetConstants(_self, config)
|
|
2622
|
+
SetConstants(config)
|
|
2623
|
+
end
|
|
2624
|
+
|
|
2574
2625
|
function GravityControllerClass:ResetGravity(gravity)
|
|
2575
2626
|
self._gravityUp = gravity
|
|
2576
2627
|
self._fallStart = self.HRP.Position:Dot(gravity)
|
|
@@ -2596,27 +2647,27 @@ end
|
|
|
2596
2647
|
|
|
2597
2648
|
--
|
|
2598
2649
|
|
|
2599
|
-
return GravityControllerClass</string>
|
|
2600
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
2601
|
-
<BinaryString name="Tags"></BinaryString>
|
|
2602
|
-
</Properties>
|
|
2603
|
-
<Item class="Folder" referent="16">
|
|
2604
|
-
<Properties>
|
|
2605
|
-
<string name="Name">CharacterModules</string>
|
|
2606
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2607
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
2608
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
2609
|
-
<BinaryString name="Tags"></BinaryString>
|
|
2610
|
-
</Properties>
|
|
2611
|
-
<Item class="ModuleScript" referent="17">
|
|
2612
|
-
<Properties>
|
|
2613
|
-
<string name="Name">Camera</string>
|
|
2614
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2615
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
2616
|
-
<Content name="LinkedSource">
|
|
2617
|
-
<null>
|
|
2618
|
-
</null>
|
|
2619
|
-
</Content>
|
|
2650
|
+
return GravityControllerClass</string>
|
|
2651
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
2652
|
+
<BinaryString name="Tags"></BinaryString>
|
|
2653
|
+
</Properties>
|
|
2654
|
+
<Item class="Folder" referent="16">
|
|
2655
|
+
<Properties>
|
|
2656
|
+
<string name="Name">CharacterModules</string>
|
|
2657
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2658
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
2659
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
2660
|
+
<BinaryString name="Tags"></BinaryString>
|
|
2661
|
+
</Properties>
|
|
2662
|
+
<Item class="ModuleScript" referent="17">
|
|
2663
|
+
<Properties>
|
|
2664
|
+
<string name="Name">Camera</string>
|
|
2665
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2666
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
2667
|
+
<Content name="LinkedSource">
|
|
2668
|
+
<null>
|
|
2669
|
+
</null>
|
|
2670
|
+
</Content>
|
|
2620
2671
|
<string name="Source">-- Class
|
|
2621
2672
|
|
|
2622
2673
|
local CameraClass = {}
|
|
@@ -2658,20 +2709,20 @@ end
|
|
|
2658
2709
|
|
|
2659
2710
|
--
|
|
2660
2711
|
|
|
2661
|
-
return CameraClass</string>
|
|
2662
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
2663
|
-
<BinaryString name="Tags"></BinaryString>
|
|
2664
|
-
</Properties>
|
|
2665
|
-
</Item>
|
|
2666
|
-
<Item class="ModuleScript" referent="18">
|
|
2667
|
-
<Properties>
|
|
2668
|
-
<string name="Name">Control</string>
|
|
2669
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2670
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
2671
|
-
<Content name="LinkedSource">
|
|
2672
|
-
<null>
|
|
2673
|
-
</null>
|
|
2674
|
-
</Content>
|
|
2712
|
+
return CameraClass</string>
|
|
2713
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
2714
|
+
<BinaryString name="Tags"></BinaryString>
|
|
2715
|
+
</Properties>
|
|
2716
|
+
</Item>
|
|
2717
|
+
<Item class="ModuleScript" referent="18">
|
|
2718
|
+
<Properties>
|
|
2719
|
+
<string name="Name">Control</string>
|
|
2720
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2721
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
2722
|
+
<Content name="LinkedSource">
|
|
2723
|
+
<null>
|
|
2724
|
+
</null>
|
|
2725
|
+
</Content>
|
|
2675
2726
|
<string name="Source">-- Class
|
|
2676
2727
|
|
|
2677
2728
|
local ControlClass = {}
|
|
@@ -2704,21 +2755,21 @@ end
|
|
|
2704
2755
|
|
|
2705
2756
|
--
|
|
2706
2757
|
|
|
2707
|
-
return ControlClass</string>
|
|
2708
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
2709
|
-
<BinaryString name="Tags"></BinaryString>
|
|
2710
|
-
</Properties>
|
|
2711
|
-
</Item>
|
|
2712
|
-
</Item>
|
|
2713
|
-
<Item class="ModuleScript" referent="19">
|
|
2714
|
-
<Properties>
|
|
2715
|
-
<string name="Name">Collider</string>
|
|
2716
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2717
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
2718
|
-
<Content name="LinkedSource">
|
|
2719
|
-
<null>
|
|
2720
|
-
</null>
|
|
2721
|
-
</Content>
|
|
2758
|
+
return ControlClass</string>
|
|
2759
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
2760
|
+
<BinaryString name="Tags"></BinaryString>
|
|
2761
|
+
</Properties>
|
|
2762
|
+
</Item>
|
|
2763
|
+
</Item>
|
|
2764
|
+
<Item class="ModuleScript" referent="19">
|
|
2765
|
+
<Properties>
|
|
2766
|
+
<string name="Name">Collider</string>
|
|
2767
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2768
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
2769
|
+
<Content name="LinkedSource">
|
|
2770
|
+
<null>
|
|
2771
|
+
</null>
|
|
2772
|
+
</Content>
|
|
2722
2773
|
<string name="Source"><![CDATA[local Maid = require(script.Parent.Utility.Maid)
|
|
2723
2774
|
|
|
2724
2775
|
local params = RaycastParams.new()
|
|
@@ -2744,7 +2795,7 @@ function ColliderClass.new(controller)
|
|
|
2744
2795
|
|
|
2745
2796
|
self.Model = Instance.new("Model")
|
|
2746
2797
|
|
|
2747
|
-
local sphere, vForce, floor, floor2, gryo = create(self, controller)
|
|
2798
|
+
local sphere, vForce, floor, floor2, gryo, bodyPosition = create(self, controller)
|
|
2748
2799
|
|
|
2749
2800
|
self._maid = Maid.new()
|
|
2750
2801
|
|
|
@@ -2755,6 +2806,7 @@ function ColliderClass.new(controller)
|
|
|
2755
2806
|
self.FloorDetector = floor
|
|
2756
2807
|
self.JumpDetector = floor2
|
|
2757
2808
|
self.Gyro = gryo
|
|
2809
|
+
self.BodyPosition = bodyPosition
|
|
2758
2810
|
|
|
2759
2811
|
init(self)
|
|
2760
2812
|
|
|
@@ -2834,6 +2886,13 @@ function create(self, controller)
|
|
|
2834
2886
|
gyro.CFrame = controller.HRP.CFrame
|
|
2835
2887
|
gyro.Parent = controller.HRP
|
|
2836
2888
|
|
|
2889
|
+
local bodyPosition = Instance.new("BodyPosition")
|
|
2890
|
+
bodyPosition.MaxForce = Vector3.new(0, 0, 0) -- Disabled by default
|
|
2891
|
+
bodyPosition.Position = controller.HRP.Position
|
|
2892
|
+
bodyPosition.P = 100000
|
|
2893
|
+
bodyPosition.D = 10000
|
|
2894
|
+
bodyPosition.Parent = controller.HRP
|
|
2895
|
+
|
|
2837
2896
|
floor.Touched:Connect(function() end)
|
|
2838
2897
|
floor2.Touched:Connect(function() end)
|
|
2839
2898
|
|
|
@@ -2841,7 +2900,7 @@ function create(self, controller)
|
|
|
2841
2900
|
floor.Parent = self.Model
|
|
2842
2901
|
floor2.Parent = self.Model
|
|
2843
2902
|
|
|
2844
|
-
return sphere, vForce, floor, floor2, gyro
|
|
2903
|
+
return sphere, vForce, floor, floor2, gyro, bodyPosition
|
|
2845
2904
|
end
|
|
2846
2905
|
|
|
2847
2906
|
function init(self)
|
|
@@ -2849,6 +2908,7 @@ function init(self)
|
|
|
2849
2908
|
self._maid:Mark(self.VForce)
|
|
2850
2909
|
self._maid:Mark(self.FloorDetector)
|
|
2851
2910
|
self._maid:Mark(self.Gyro)
|
|
2911
|
+
self._maid:Mark(self.BodyPosition)
|
|
2852
2912
|
self.Model.Name = "Collider"
|
|
2853
2913
|
self.Model.Parent = self.Controller.Character
|
|
2854
2914
|
end
|
|
@@ -2860,6 +2920,35 @@ function ColliderClass:Update(force, cframe)
|
|
|
2860
2920
|
self.Gyro.CFrame = cframe
|
|
2861
2921
|
end
|
|
2862
2922
|
|
|
2923
|
+
function ColliderClass:SetHorizontalLock(enabled, lockPosition, surfaceNormal)
|
|
2924
|
+
if enabled then
|
|
2925
|
+
-- Lock position to prevent sliding when on aligned surface with no input
|
|
2926
|
+
-- Only lock if we don't already have a lock, or update it
|
|
2927
|
+
if self.BodyPosition.MaxForce.Magnitude == 0 then
|
|
2928
|
+
-- Setting initial lock position
|
|
2929
|
+
self._lockedPosition = lockPosition
|
|
2930
|
+
end
|
|
2931
|
+
-- Keep position locked (update to current position to allow vertical adjustments)
|
|
2932
|
+
-- But constrain horizontal movement by only allowing movement along surface normal
|
|
2933
|
+
local currentPos = self.Controller.HRP.Position
|
|
2934
|
+
local positionAlongNormal = currentPos:Dot(surfaceNormal)*surfaceNormal
|
|
2935
|
+
-- Keep horizontal position from when lock was enabled
|
|
2936
|
+
if self._lockedPosition then
|
|
2937
|
+
local lockedPosAlongNormal = self._lockedPosition:Dot(surfaceNormal)*surfaceNormal
|
|
2938
|
+
local lockedHorizontalPos = self._lockedPosition - lockedPosAlongNormal
|
|
2939
|
+
-- Combine: use current vertical position but locked horizontal position
|
|
2940
|
+
self.BodyPosition.Position = lockedHorizontalPos + positionAlongNormal
|
|
2941
|
+
else
|
|
2942
|
+
self.BodyPosition.Position = lockPosition
|
|
2943
|
+
end
|
|
2944
|
+
self.BodyPosition.MaxForce = Vector3.new(100000, 100000, 100000)
|
|
2945
|
+
else
|
|
2946
|
+
-- Disable constraint
|
|
2947
|
+
self.BodyPosition.MaxForce = Vector3.new(0, 0, 0)
|
|
2948
|
+
self._lockedPosition = nil
|
|
2949
|
+
end
|
|
2950
|
+
end
|
|
2951
|
+
|
|
2863
2952
|
function ColliderClass:IsGrounded(isJumpCheck)
|
|
2864
2953
|
local parts = (isJumpCheck and self.JumpDetector or self.FloorDetector):GetTouchingParts()
|
|
2865
2954
|
for _, part in pairs(parts) do
|
|
@@ -2867,6 +2956,19 @@ function ColliderClass:IsGrounded(isJumpCheck)
|
|
|
2867
2956
|
return true
|
|
2868
2957
|
end
|
|
2869
2958
|
end
|
|
2959
|
+
return false
|
|
2960
|
+
end
|
|
2961
|
+
|
|
2962
|
+
function ColliderClass:CorrectPositionIfStuck(gravityUp)
|
|
2963
|
+
params2.FilterDescendantsInstances = {self.Controller.Character}
|
|
2964
|
+
local rayResult = workspace:Raycast(self.Sphere.Position, -gravityUp * 3, params2)
|
|
2965
|
+
if rayResult and rayResult.Instance and rayResult.Instance.CanCollide then
|
|
2966
|
+
local heightAboveHit = (self.Sphere.Position - rayResult.Position):Dot(gravityUp)
|
|
2967
|
+
if heightAboveHit < .95 then
|
|
2968
|
+
local delta = (rayResult.Position + gravityUp * 1.05) - self.Sphere.Position
|
|
2969
|
+
self.Controller.HRP.CFrame = self.Controller.HRP.CFrame + delta
|
|
2970
|
+
end
|
|
2971
|
+
end
|
|
2870
2972
|
end
|
|
2871
2973
|
|
|
2872
2974
|
function ColliderClass:GetStandingPart()
|
|
@@ -2878,6 +2980,18 @@ function ColliderClass:GetStandingPart()
|
|
|
2878
2980
|
return result and result.Instance
|
|
2879
2981
|
end
|
|
2880
2982
|
|
|
2983
|
+
function ColliderClass:GetSurfaceNormal()
|
|
2984
|
+
params2.FilterDescendantsInstances = {self.Controller.Character}
|
|
2985
|
+
|
|
2986
|
+
local gravityUp = self.Controller._gravityUp
|
|
2987
|
+
local result = workspace:Raycast(self.Sphere.Position, -1.1*gravityUp, params2)
|
|
2988
|
+
|
|
2989
|
+
if result and result.Normal then
|
|
2990
|
+
return result.Normal
|
|
2991
|
+
end
|
|
2992
|
+
return nil
|
|
2993
|
+
end
|
|
2994
|
+
|
|
2881
2995
|
function ColliderClass:Destroy()
|
|
2882
2996
|
self._maid:Sweep()
|
|
2883
2997
|
end
|
|
@@ -2885,20 +2999,20 @@ end
|
|
|
2885
2999
|
--
|
|
2886
3000
|
|
|
2887
3001
|
return ColliderClass
|
|
2888
|
-
]]></string>
|
|
2889
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
2890
|
-
<BinaryString name="Tags"></BinaryString>
|
|
2891
|
-
</Properties>
|
|
2892
|
-
</Item>
|
|
2893
|
-
<Item class="ModuleScript" referent="20">
|
|
2894
|
-
<Properties>
|
|
2895
|
-
<string name="Name">StateTracker</string>
|
|
2896
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
2897
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
2898
|
-
<Content name="LinkedSource">
|
|
2899
|
-
<null>
|
|
2900
|
-
</null>
|
|
2901
|
-
</Content>
|
|
3002
|
+
]]></string>
|
|
3003
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
3004
|
+
<BinaryString name="Tags"></BinaryString>
|
|
3005
|
+
</Properties>
|
|
3006
|
+
</Item>
|
|
3007
|
+
<Item class="ModuleScript" referent="20">
|
|
3008
|
+
<Properties>
|
|
3009
|
+
<string name="Name">StateTracker</string>
|
|
3010
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
3011
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
3012
|
+
<Content name="LinkedSource">
|
|
3013
|
+
<null>
|
|
3014
|
+
</null>
|
|
3015
|
+
</Content>
|
|
2902
3016
|
<string name="Source">local Maid = require(script.Parent.Utility.Maid)
|
|
2903
3017
|
local Signal = require(script.Parent.Utility.Signal)
|
|
2904
3018
|
|
|
@@ -3007,28 +3121,28 @@ function StateTrackerClass:Destroy()
|
|
|
3007
3121
|
self._maid:Sweep()
|
|
3008
3122
|
end
|
|
3009
3123
|
|
|
3010
|
-
return StateTrackerClass</string>
|
|
3011
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
3012
|
-
<BinaryString name="Tags"></BinaryString>
|
|
3013
|
-
</Properties>
|
|
3014
|
-
</Item>
|
|
3015
|
-
<Item class="Folder" referent="21">
|
|
3016
|
-
<Properties>
|
|
3017
|
-
<string name="Name">Utility</string>
|
|
3018
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
3019
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
3020
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
3021
|
-
<BinaryString name="Tags"></BinaryString>
|
|
3022
|
-
</Properties>
|
|
3023
|
-
<Item class="ModuleScript" referent="22">
|
|
3024
|
-
<Properties>
|
|
3025
|
-
<string name="Name">Maid</string>
|
|
3026
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
3027
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
3028
|
-
<Content name="LinkedSource">
|
|
3029
|
-
<null>
|
|
3030
|
-
</null>
|
|
3031
|
-
</Content>
|
|
3124
|
+
return StateTrackerClass</string>
|
|
3125
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
3126
|
+
<BinaryString name="Tags"></BinaryString>
|
|
3127
|
+
</Properties>
|
|
3128
|
+
</Item>
|
|
3129
|
+
<Item class="Folder" referent="21">
|
|
3130
|
+
<Properties>
|
|
3131
|
+
<string name="Name">Utility</string>
|
|
3132
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
3133
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
3134
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
3135
|
+
<BinaryString name="Tags"></BinaryString>
|
|
3136
|
+
</Properties>
|
|
3137
|
+
<Item class="ModuleScript" referent="22">
|
|
3138
|
+
<Properties>
|
|
3139
|
+
<string name="Name">Maid</string>
|
|
3140
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
3141
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
3142
|
+
<Content name="LinkedSource">
|
|
3143
|
+
<null>
|
|
3144
|
+
</null>
|
|
3145
|
+
</Content>
|
|
3032
3146
|
<string name="Source">-- CONSTANTS
|
|
3033
3147
|
|
|
3034
3148
|
local FORMAT_STR = "Maid does not support type \"%s\""
|
|
@@ -3099,20 +3213,20 @@ MaidClass.Destroy = MaidClass.Sweep
|
|
|
3099
3213
|
|
|
3100
3214
|
--
|
|
3101
3215
|
|
|
3102
|
-
return MaidClass</string>
|
|
3103
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
3104
|
-
<BinaryString name="Tags"></BinaryString>
|
|
3105
|
-
</Properties>
|
|
3106
|
-
</Item>
|
|
3107
|
-
<Item class="ModuleScript" referent="23">
|
|
3108
|
-
<Properties>
|
|
3109
|
-
<string name="Name">Signal</string>
|
|
3110
|
-
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
3111
|
-
<bool name="DefinesCapabilities">false</bool>
|
|
3112
|
-
<Content name="LinkedSource">
|
|
3113
|
-
<null>
|
|
3114
|
-
</null>
|
|
3115
|
-
</Content>
|
|
3216
|
+
return MaidClass</string>
|
|
3217
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
3218
|
+
<BinaryString name="Tags"></BinaryString>
|
|
3219
|
+
</Properties>
|
|
3220
|
+
</Item>
|
|
3221
|
+
<Item class="ModuleScript" referent="23">
|
|
3222
|
+
<Properties>
|
|
3223
|
+
<string name="Name">Signal</string>
|
|
3224
|
+
<BinaryString name="AttributesSerialize"></BinaryString>
|
|
3225
|
+
<bool name="DefinesCapabilities">false</bool>
|
|
3226
|
+
<Content name="LinkedSource">
|
|
3227
|
+
<null>
|
|
3228
|
+
</null>
|
|
3229
|
+
</Content>
|
|
3116
3230
|
<string name="Source">-- Taken from Quenty's nevermore engine
|
|
3117
3231
|
-- https://github.com/Quenty/NevermoreEngine/blob/version2/LICENSE.md
|
|
3118
3232
|
-- https://github.com/Quenty/NevermoreEngine
|
|
@@ -3197,12 +3311,12 @@ function Signal:Destroy()
|
|
|
3197
3311
|
setmetatable(self, nil)
|
|
3198
3312
|
end
|
|
3199
3313
|
|
|
3200
|
-
return Signal</string>
|
|
3201
|
-
<int64 name="SourceAssetId">-1</int64>
|
|
3202
|
-
<BinaryString name="Tags"></BinaryString>
|
|
3203
|
-
</Properties>
|
|
3204
|
-
</Item>
|
|
3205
|
-
</Item>
|
|
3206
|
-
</Item>
|
|
3207
|
-
</Item>
|
|
3208
|
-
</roblox>
|
|
3314
|
+
return Signal</string>
|
|
3315
|
+
<int64 name="SourceAssetId">-1</int64>
|
|
3316
|
+
<BinaryString name="Tags"></BinaryString>
|
|
3317
|
+
</Properties>
|
|
3318
|
+
</Item>
|
|
3319
|
+
</Item>
|
|
3320
|
+
</Item>
|
|
3321
|
+
</Item>
|
|
3322
|
+
</roblox>
|