@@ -26,94 +26,94 @@ local RagdollMotorUtils = {}
2626
2727local R6_MOTORS = {
2828 {
29- partName = " Torso" ;
30- motorName = " Root" ;
31- isRootJoint = true ;
32- };
29+ partName = " Torso" ,
30+ motorName = " Root" ,
31+ isRootJoint = true ,
32+ },
3333 {
34- partName = " Torso" ;
35- motorName = " Neck" ;
36- };
34+ partName = " Torso" ,
35+ motorName = " Neck" ,
36+ },
3737 {
38- partName = " Torso" ;
39- motorName = " Left Shoulder" ;
40- };
38+ partName = " Torso" ,
39+ motorName = " Left Shoulder" ,
40+ },
4141 {
42- partName = " Torso" ;
43- motorName = " Right Shoulder" ;
44- };
42+ partName = " Torso" ,
43+ motorName = " Right Shoulder" ,
44+ },
4545 {
46- partName = " Torso" ;
47- motorName = " Left Hip" ;
48- };
46+ partName = " Torso" ,
47+ motorName = " Left Hip" ,
48+ },
4949 {
50- partName = " Torso" ;
51- motorName = " Right Hip" ;
52- };
50+ partName = " Torso" ,
51+ motorName = " Right Hip" ,
52+ },
5353}
5454
5555local R15_MOTORS = {
5656 {
57- partName = " LowerTorso" ;
58- motorName = " Root" ;
59- isRootJoint = true ;
60- };
57+ partName = " LowerTorso" ,
58+ motorName = " Root" ,
59+ isRootJoint = true ,
60+ },
6161 {
62- partName = " UpperTorso" ;
63- motorName = " Waist" ;
64- };
62+ partName = " UpperTorso" ,
63+ motorName = " Waist" ,
64+ },
6565 {
66- partName = " Head" ;
67- motorName = " Neck" ;
68- };
66+ partName = " Head" ,
67+ motorName = " Neck" ,
68+ },
6969 {
70- partName = " LeftUpperArm" ;
71- motorName = " LeftShoulder" ;
72- };
70+ partName = " LeftUpperArm" ,
71+ motorName = " LeftShoulder" ,
72+ },
7373 {
74- partName = " LeftLowerArm" ;
75- motorName = " LeftElbow" ;
76- };
74+ partName = " LeftLowerArm" ,
75+ motorName = " LeftElbow" ,
76+ },
7777 {
78- partName = " LeftHand" ;
79- motorName = " LeftWrist" ;
80- };
78+ partName = " LeftHand" ,
79+ motorName = " LeftWrist" ,
80+ },
8181 {
82- partName = " RightUpperArm" ;
83- motorName = " RightShoulder" ;
84- };
82+ partName = " RightUpperArm" ,
83+ motorName = " RightShoulder" ,
84+ },
8585 {
86- partName = " RightLowerArm" ;
87- motorName = " RightElbow" ;
88- };
86+ partName = " RightLowerArm" ,
87+ motorName = " RightElbow" ,
88+ },
8989 {
90- partName = " RightHand" ;
91- motorName = " RightWrist" ;
92- };
90+ partName = " RightHand" ,
91+ motorName = " RightWrist" ,
92+ },
9393 {
94- partName = " LeftUpperLeg" ;
95- motorName = " LeftHip" ;
96- };
94+ partName = " LeftUpperLeg" ,
95+ motorName = " LeftHip" ,
96+ },
9797 {
98- partName = " LeftLowerLeg" ;
99- motorName = " LeftKnee" ;
100- };
98+ partName = " LeftLowerLeg" ,
99+ motorName = " LeftKnee" ,
100+ },
101101 {
102- partName = " LeftFoot" ;
103- motorName = " LeftAnkle" ;
104- };
102+ partName = " LeftFoot" ,
103+ motorName = " LeftAnkle" ,
104+ },
105105 {
106- partName = " RightUpperLeg" ;
107- motorName = " RightHip" ;
108- };
106+ partName = " RightUpperLeg" ,
107+ motorName = " RightHip" ,
108+ },
109109 {
110- partName = " RightLowerLeg" ;
111- motorName = " RightKnee" ;
112- };
110+ partName = " RightLowerLeg" ,
111+ motorName = " RightKnee" ,
112+ },
113113 {
114- partName = " RightFoot" ;
115- motorName = " RightAnkle" ;
116- };
114+ partName = " RightFoot" ,
115+ motorName = " RightAnkle" ,
116+ },
117117}
118118
119119local ROOT_JOINT_CACHE = {}
@@ -193,19 +193,12 @@ function RagdollMotorUtils.setupRagdollRootPartMotor(motor, part0, part1)
193193
194194 -- Inserted C1/C0 here
195195 weldMaid :GiveTask (Rx .combineLatest ({
196- C0 = RxInstanceUtils .observeProperty (motor , " C0" );
197- Transform = RxInstanceUtils .observeProperty (transformValue , " Value" );
196+ C0 = RxInstanceUtils .observeProperty (motor , " C0" ),
197+ Transform = RxInstanceUtils .observeProperty (transformValue , " Value" ),
198198 }):Subscribe (function (innerState )
199199 weld .C0 = innerState .C0 * innerState .Transform
200200 end ))
201201
202- if weld :IsA (" Motor6D" ) then
203- -- Suppress animations on any weld connection
204- weldMaid :GiveTask (RunService .Stepped :Connect (function ()
205- weld .Transform = CFrame .new ()
206- end ))
207- end
208-
209202 weldMaid :GiveTask (RxInstanceUtils .observeProperty (motor , " C1" ):Subscribe (function (c1 )
210203 weld .C1 = c1
211204 end ))
@@ -225,18 +218,8 @@ function RagdollMotorUtils.setupRagdollRootPartMotor(motor, part0, part1)
225218 maid ._weld = setupWeld (" Weld" )
226219 end
227220
228- maid :GiveTask (ragdollMotorData .RagdollSpringReturnSpeed :Observe ()
229- :Subscribe (function (speed )
230- lastTransformSpring .s = speed
231- end ))
232-
233- -- Lerp smoothly to 0 to avoid jarring camera.
234- maid :GiveTask (RunService .Stepped :Connect (function ()
235- local target = QFrame .toCFrame (lastTransformSpring .p )
236- if target then
237- transformValue .Value = target
238- motor .Transform = target
239- end
221+ maid :GiveTask (ragdollMotorData .RagdollSpringReturnSpeed :Observe ():Subscribe (function (speed )
222+ lastTransformSpring .s = speed
240223 end ))
241224
242225 motor .Enabled = false
@@ -280,12 +263,12 @@ function RagdollMotorUtils.suppressJustRootPart(character, rigType)
280263 local ragdollMotorData = RagdollMotorData :Create (motor )
281264
282265 return Rx .combineLatest ({
283- motor = motor ;
284- part0 = RxInstanceUtils .observeProperty (motor , " Part0" );
285- part1 = RxInstanceUtils .observeProperty (motor , " Part1" );
286- isAnimated = ragdollMotorData .IsMotorAnimated :Observe ();
266+ motor = motor ,
267+ part0 = RxInstanceUtils .observeProperty (motor , " Part0" ),
268+ part1 = RxInstanceUtils .observeProperty (motor , " Part1" ),
269+ isAnimated = ragdollMotorData .IsMotorAnimated :Observe (),
287270 })
288- end );
271+ end ),
289272 })
290273
291274 local topMaid = Maid .new ()
@@ -324,12 +307,12 @@ function RagdollMotorUtils.suppressMotors(character, rigType, velocityReadings)
324307 local ragdollMotorData = RagdollMotorData :Create (motor )
325308
326309 return RxBrioUtils .flatCombineLatest ({
327- motor = motor ;
328- part0 = RxInstanceUtils .observeProperty (motor , " Part0" );
329- part1 = RxInstanceUtils .observeProperty (motor , " Part1" );
330- isAnimated = ragdollMotorData .IsMotorAnimated :Observe ();
310+ motor = motor ,
311+ part0 = RxInstanceUtils .observeProperty (motor , " Part0" ),
312+ part1 = RxInstanceUtils .observeProperty (motor , " Part1" ),
313+ isAnimated = ragdollMotorData .IsMotorAnimated :Observe (),
331314 })
332- end );
315+ end ),
333316 })
334317
335318 topMaid :GiveTask (observable :Subscribe (function (brio )
@@ -348,7 +331,8 @@ function RagdollMotorUtils.suppressMotors(character, rigType, velocityReadings)
348331 motorMaid ._current = RagdollMotorUtils .setupAnimatedMotor (character , state .part1 )
349332 else
350333 if data .isRootJoint then
351- motorMaid ._current = RagdollMotorUtils .setupRagdollRootPartMotor (state .motor , state .part0 , state .part1 )
334+ motorMaid ._current =
335+ RagdollMotorUtils .setupRagdollRootPartMotor (state .motor , state .part0 , state .part1 )
352336 else
353337 motorMaid ._current = RagdollMotorUtils .setupRagdollMotor (state .motor , state .part0 , state .part1 )
354338 end
@@ -417,10 +401,10 @@ function RagdollMotorUtils.promiseVelocityRecordings(character, rigType)
417401 local part1 = motor .Part1
418402 if part0 and part1 then
419403 parts [data ] = {
420- motor = motor ;
421- part0 = part0 ;
422- part1 = part1 ;
423- relCFrame = initialRootPartCFrame :toObjectSpace (part1 .CFrame );
404+ motor = motor ,
405+ part0 = part0 ,
406+ part1 = part1 ,
407+ relCFrame = initialRootPartCFrame :toObjectSpace (part1 .CFrame ),
424408 }
425409 end
426410 end
@@ -434,9 +418,9 @@ function RagdollMotorUtils.promiseVelocityRecordings(character, rigType)
434418 local newRootPartCFrame = rootPart .CFrame
435419
436420 local result = {
437- readingTimePhysics = time ();
438- linear = {};
439- rotation = {};
421+ readingTimePhysics = time (),
422+ linear = {},
423+ rotation = {},
440424 }
441425
442426 for data , info in pairs (parts ) do
@@ -445,15 +429,15 @@ function RagdollMotorUtils.promiseVelocityRecordings(character, rigType)
445429 -- Validate all the same
446430 if info .motor == motor and info .part0 == motor .Part0 and info .part1 == motor .Part1 then
447431 local linear = newRootPartCFrame :pointToObjectSpace (info .part1 .Position ) - info .relCFrame .p
448- result .linear [data ] = newRootPartCFrame :vectorToWorldSpace (linear / dt )
432+ result .linear [data ] = newRootPartCFrame :vectorToWorldSpace (linear / dt )
449433
450434 local change = info .relCFrame :toObjectSpace (newRootPartCFrame :toObjectSpace (info .part1 .CFrame ))
451435
452436 -- assume that we're XYZ ordered
453437 local x , y , z = change :ToEulerAnglesXYZ ()
454438
455439 local vector = newRootPartCFrame :vectorToWorldSpace (Vector3 .new (x , y , z ))
456- result .rotation [data ] = vector / dt
440+ result .rotation [data ] = vector / dt
457441 end
458442 end
459443
@@ -473,4 +457,4 @@ function RagdollMotorUtils.yieldUntilStepped()
473457 return dt
474458end
475459
476- return RagdollMotorUtils
460+ return RagdollMotorUtils
0 commit comments